perm filename DIRED.FAI[CSP,SYS]9 blob sn#334012 filedate 1978-02-14 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00043 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00004 00002	TITLE PAGE
C00005 00003	 Random Blocks and Defs 
C00022 00004	DMSWAP DMGO GO NODM GO2 RCYCLE RCYCL1
C00025 00005	 Main loop.  Display, Decode, Execute 
C00031 00006	 Switch Decoder 
C00035 00007	 Cursor up and down 
C00049 00008	 Window up and down 
C00054 00009	 Enter E on current file 
C00058 00010	 Delete  HAS BEEN DELETED
C00064 00011	 New Delete System 
C00073 00012	 Put up new arrow 
C00075 00013	 Exit to DDT or World 
C00076 00014	 Run Delete list, and clear 
C00081 00015	 Gobble argument 
C00082 00016	 Put up a display 
C00093 00017	 Initialization 
C00095 00018	 Read UFD and produce FILES table 
C00107 00019	 Line Editing 
C00113 00020	 Produce english for line editor 
C00114 00021	 Produce english of of file pointed to by A in DIRLIN 
C00122 00022	 Sort the files 
C00126 00023	 Switch Code 
C00135 00024	 Print a bit of this file 
C00136 00025	 Read PPN 
C00139 00026	 Read a Mask 
C00146 00027	 Output Text to Random Device 
C00151 00028	 Files Spooled Here.  No cost, no obligation 
C00155 00029	 FNR for /OUTPUT command 
C00159 00030	 Trivia 
C00164 00031	 Temp core 
C00169 00032	 To err is human, to forgive, Divine 
C00172 00033	 Help a luser 
C00182 00034	 UUO Handler 
C00184 00035		GET uuo 
C00187 00036		SGEN uuo 
C00188 00037		SPRINT uuo 
C00189 00038	 	FLOOKUP uuo 
C00192 00039	 	REMOVE uuo 
C00195 00040	 	TYPE6 uuo 
C00196 00041	 	TTY6 uuo 
C00197 00042	 Usage lossage 
C00202 00043	END GO
C00203 ENDMK
C⊗;
;TITLE PAGE
TITLE DIRED

;(C) 1974 by Stanley G. Kugell.  All rights reserved.
;The name Dired, the program and design are the property of the author.

;DOCUMENT IN DIRED.SGK[UP,DOC]
;Warning to would be hackers: this program is a crock of shit.  The idea
;ain't so bad, but this program was only intended to test the utility
;of the idea.  Unf, I never wrote the real thing.
COMMENT ⊗ Random Blocks and Defs ⊗


A←1
B←2
C←3
D←4
E←5
P←6	;PUSH DOWN LIST 1
I←7
II←10
F←11
L←12	;L K J ARE USED BY RUBIN'S FNR KLUDGE ONLY
K←13
J←14
Q←17	;PUSH DOWN LIST 2

NEWUFD←←1	;ASSEMBLE FOR LONG UFD ENTRIES

DEFINE CONC!(CONCA,CONCB)<CONCA!CONCB>

DEFINE INSIRP (INST,ADDS) <
	FOR ZZZ IN (B) <
	A,ZZZ
	>
	>
DEFINE SWGARDEN (HERETH)	;ERE, EVERYWHERE.  SURROUNDED BY SWITCHES!
	;DO THE STANDARD ESCAPE TRICK AFTER DEALING WITH A SWITCH
	<
	TRNN F,%START	;DIRECT IF TAKING SWITCHES FROM COMMAND LINE
	JRST RIHANG ;GET SOME MORE
	TRNN F,%RRUFD	;IF WE HAVE REC. A FILE NAME MUST RCYCLE
	JRST HERETH	;CONTINUE HACKING IN WAY SPECIFIED BY CALLER
	JRST RCYCLE	;ONE OF THE FNR'S DID A JRST SWITCH, WE MUST DO LONGLOOP PASS
	>

DEFINE GETFIL $ (LE,STR,LH,CH,BUF,BYTE,HAKRET)
<ZZ←←.
IFDIF <STR><><OUTSTR [ASCIZ /$STR$/]>
	PUSHJ P,FILSCN	;INPUT FILE SPECS
IFIDN <LE> <L> <LH,,LUP>
IFIDN <LE> <E> <LH,,ENT>
	JRST [	CRLF		;ALT TYPED
		JRST HAKRET]
	JRST [	OUTSTR [ASCIZ /Ho Ho!	;GARBAGE TYPED
/]
		CLRBFI
		JRST ZZ]
	INIT CH,10
	'DSK   '
IFIDN <LE> <E> <BUF,,> IFIDN <LE> <L> <BUF>
	JRST INITL
IFIDN <LE> <L> <LOOKUP CH,LUP
	JRST [	PUSHJ P,LUPFL
		JRST ZZ]>
IFIDN <LE> <E> <ENTER CH,ENT
	JRST [	PUSHJ P,ENTFL
		JRST ZZ]>
	MOVEI A,BYTE
	DPB A,[300600,,BUF+1]
>

DEFINE CRLF
<	OUTCHR [15]
	OUTCHR [12]
>

DEFINE FIXGAP (AC0,TABLE,LENGTH,GAPSIZ)
	;CLOSE GAP IN TABLE, STARTING AT
	;TABLE (AC0), OF LENGTH 'GAPSIZ'.  LENGTH← TABLE LENGTH
	<
	ADDI AC0,TABLE	;TURN THE IDX AC INTO POINTER
	HRLI AC0,GAPSIZ(AC0) ;TURN PTR. INTO <END OF GAP + 1>,,<BEGINING OF GAP>
	BLT AC0,TABLE+LENGTH-1	;BLT <END OF GAP + 1> (FIRST REAL GOODIES) UP
	>	;FIXGAP

DEFINE CW(C1,B1,C2,B2,C3,B3) <
	<BYTE (8)<B1>,<B2>,<B3> (3)<C1>,<C2>,<C3>>!4
>
DEFINE ISTHIS (AC,GOTO,CHAR,CONDCL,CONDMT,CONDCM)	<

IFE "CONDCL"-"T",<	;IF CONTROL !CHR! IS ONE OF THE THINGS HE LOOKING FOR
	CAIE AC,200+"CHAR"	;α CHAR?
	CAIN AC,200+"CHAR"+40	;OR α char?
	JRST GOTO		;THEN GO WHERE WE WERE TOLD TO
	>	;CONDCL
IFE "CONDMT"-"T",<	;IF META !CHR! IS ONE OF THE CHRS HE WANTS TO JRST ON
	CAIE AC,400+"CHAR"	;β CHAR?
	CAIN AC,400+"CHAR"+40	;OR COULD IT BE β char
	JRST GOTO		;DO IT
	>	;CONDMT (CONDITION META)
IFE "CONDCM"-"T",<		;IF CONTROL META !CHAR! IS SUPPOSED TO BE RECOGNIZED
	CAIE AC,600+"CHAR"
	CAIN AC,600+"CHAR"+40
	JRST GOTO
	>	;CONDCM	(CONDITION CONTROL META)
	>	;DEFINE ISTHIS
	
DEFINE ERR (CODE,MSG,INS,MSG1)	<
	JRST	[
		IFE CODE,<PUSHJ P,CLEAR>	;ONLY CLR WHEN CODE IS 0
		OUTSTR [ASCIZ ≡MSG≡]
		INS		;EXECUTE THIS GUYS INSTRUCTION IF HE GAVE ONE
		OUTSTR [ASCIZ ≡MSG1≡]
		MOVEI .
		CLRBFI
		EXIT]
>	;DEFINE ERR

DEFINE PUT (TOO,FROM) <
	PUSH P,
	MOVE FROM
	MOVEM TOO
	POP P,
	>
DEFINE ARGET (B0,B1,B2) <;PUT POS. ARG IN B0, IF NONE DEFAULT TO A1, IF NEG. GIVE TO A2
	SKIPE ARGSGN↔JRST [SETZM ARGSGN↔JRST B2]↔SKIPE ARGF↔SKIPA B0,ARG↔MOVEI B0,B1
	>

DEFINE ... < JRST 4,. >

;DD COMMAND DEFS
	EXCT←←0↔FNCN←←1↔CHNL←←2↔COLM←←3↔HILIN←←4↔LOLIN←←5↔ALPHA←←46

;RIGHT HALF FLAGS
	%START←←1	; 0==> READING MONITOR COMMAND LINE, IN GENERAL, RETURN TO RIHANG
			; IN THIS MODE, 1==> LINE READ, UFD READ (OR BEING READ)
	%SORT←←2	; 0==> SORT BY ALPHA, 1==> SORT BY DATE
	%GETTY←←4	; 0==> DD, 1==> III DISPLAY
	%DEBUG←←10	; 0==> NOTHING, 1==> DEBUG MODE FOR WHAT ITS WORTH
	%UDP←←20	; 0 ==> EDIT FROM DSK, 1==> USE UDP
	%ORDER←←40	; 1==> REVERSE SORT
	%DISPLAY←←100	; 1==> DISPLAYING DELETE LIST, NOT FILES
	%NOOK←←200	; 1==> INHIBIT TYPING "OK".  COMMANDS SET, OCYCLE RESETS
	%TCORE←←400	; 1==> TMPCOR FILE WAS FOUND AND READ.  RESET AT RCYCLE
	%DEVUO←←1000	; 1==> 'BP7' UUOS OUTPUT TO FIL CHAN, NOT BP7
	%KMODE←←2000	; 1==> PRINT FILE SIZES LARGER THAN 1000 IN K'S
	%XTSRT←←4000	; IF %SORT IS 0
			;	0==> SORT BY FULL FILE NAME
			;	1==> SORT WITH FILE NAME AND EXT SWITCHED IN SIGNIFICANCE
			; IF %SORT OR %SZSRT = 1, BIT IS UNUSED
	%DDELS←←10000	; 1==> DISPLAY DELETE LIST, NOT FILES
	%RRUFD←←20000	; 1==> MUST RE READ UFD, GETS RESET AT RCYCLE WHILE DELETEIN
	%FAST←←40000	; 1==> INHIBIT LOOKUPS, DONT DELETE FILES, ETC.  FAST MODE
	%SZSRT←100000	; 1==> SORT BY SIZE.  PRECEDENCE OVR %SORT AND %XTSRT
	%TTY←←200000	; 1==> NO DPY.  JUST LIST SORTED FILES.
	%READO←←400000	; 1==> READONLY MODE.  DONT DO ANY DELETES

;BLOCK SIZES
	PDS←←=69
	QPDS←←20	;Q PDL SIZE
	FIL←←2		;DELETES ON THIS CHAN. RANDOM IO HERE
	FILC←←1		;CHAN. FOR LONG LOOKUP
	UFDC←←0		;UFD CHAN
	MFDC←←3		;READ [1,1] HERE WHEN THERE IS A PPN WITH ∀'S
	NFILES←←1000	;NUMBER OF FILES PROGRAM SHOULD BE ABLE TO TAKE CARE OF
	NLINES←←35	;NUMBER OF DISPLAY LINES
	DIRLEN←←=30*NLINES;LENGTH OF OUTPUT AREA FOR GENTXT
	GLTP←←0		;GLITCH SCREEN IF THIS CLOSE TO EDGE OF WINDOW
	GLTBY←←3	;WHEN GLITCHING, DO SO BY THIS AMOUNT
	IIITOP←←600	;Y POS OF FIRST DIRECTORY LINE
;	...←←0		;UNFINISHED CODE
BP7:	-1		;BYTE POINTER FOR GENTXT
PATCH:	PAT:	BLOCK 100

IIHEAD:	0
IIMUNG:	BYTE (11)<-1020>,IIITOP (3)2,2 (1)0,1 (2)2 (4)6
	ASCID /→/
	BYTE (11)<-1000>,710 (3)2,2 (1)0,1 (2)2 (4)6
	DIRLIN,,20

DDHEAD:	CW FNCN,ALPHA,FNCN,ALPHA,FNCN,ALPHA
DDMUNG:	CW COLM,2,HILIN,1,LOLIN,11 ;13?
DIRLIN:	BLOCK DIRLEN	;BUFFER FOR GEN. OF ENGLISH OF DIRECTORY
	CW EXCT,0,CHNL,0,CHNL,0
ZERO:	0		;FOR END OF DD PROGRAM.  IF THIS IS NON-ZERO YOU ARE LOSING


	XALL
LUKDAT:	REPEAT NFILES*7+1,{
	-1};UFDREAD STUFFS LOOKUP DATA IN HERE FOR INDIV FILES
	LALL

DDARRO:	CW FNCN,66,COLM,1,CHNL,0
DDAMUN:	CW CHNL,0,HILIN,0,LOLIN,0
	ASCID /→/
	CW EXCT,0,CHNL,0,CHNL,0
	0
DDFLSA:	CW FNCN,66,COLM,1,CHNL,0
DDFMUN:	0	;GETS SET UP
	ASCID / /
	CW EXCT,0,CHNL,0,CHNL,0
	0


MMASK:	-1	;MASTER MASK FOR READ UFD LEVEL.  -1 IMPLIES ANY CHARACTER
	-1	; PARTICULAR CHR (STORED IN SIXBIT) IS THAT CHR.
	-1
	-1
	-1
	-1
MMASK2:	-1	;THIS IS THE EXT. FOR MASTER MASK.
	-1
	-1
WORDS:	-1		;MAINTAINS COUNT OF TOTAL NUMBER OF WORDS IN USER'S DIRECT
CURFIL:	-1		;CURRENT FILE USER THINKING ABOUT (IDX INTO FILES)
DIPFIL:	-1		;FIRST FILE DISPLAYED FROM TOP (INDX INTO FILES)
CURFIS:	-1		;CURFIL GETS HIDDEN HERE WHILE WE IN DELETE LIST MODE
DIPFIS:	-1		;DIPFIL GETS STUFFED HERE WHEN ENTERING DELETE LIST MODE
TFILE:	-1		;NUMBER OF FILES (TFILE-1 IS HIGHEST INDEX INTO FILES USED)
TFILE1:	-1		;LARGEST INDEX INTO FILES (TFILE-1), LARGEST CURFIL SHLD B.
TFILES:	-1		;TFILE IS HIDDEN HERE WHEN IN DELETE LIST MODE
DDSELP:	0		;WHEN -1 CLEAR DOES NOT GO BACK TO PAGE 0
ANYWHO:	0		;0==>FAST MODE, FREE AND CLEAR. 1==> AT LEAST 1 FILE HAS BEEN LOOKED UP
FLKDAT:	0		;FLOOKUP UUO LEAVES POINTER TO DATA HERE
UFDIN:	BLOCK 6		;WHERE LONG LOOKUPS LEAVE DATA
SPLBLK:	BLOCK 4		;HERE THE SPOOL INSERT LOSS USES AS LOOKUP BLOCK
LUSER:	-1		;PPN OF LUSER LUSING
RENBLK:	BLOCK 6		;RENAME TO DELETE HAPPENS HERE (USED FOR BTH LONG AND SHORT REN'S)
DELBLK:	'......'	;LOOKUPS FOR DELETING HAPPEN HERE, THEREFORE HAS NAME OF FIL
	BLOCK 3		; LAST DELETED IN IN.  SIMULATE '......' FOR IT.
FILNUL:	BLOCK 3		;DUMMY BUFFER HEADER FOR LONG LOOKUP'S INIT
MFDNUL:	BLOCK 3		;HEADER FOR MFD CHAN
UFDNUL:	BLOCK 3		;HEADER FOR UFD CHAN
UFDB:	BLOCK 4		;LOOKUP BLOCK ON UFD FILE
DATES:	BLOCK NFILES	;HAVE FILE DATES IN UFD ORDER PUT IN HERE
;these are ufd tables
UFD:	BLOCK NFILES	;STORE FIRST WORD OF EACH UFD ENTRY HERE
UFD2:	BLOCK NFILES	;STORE SECOND WORD OF UFD ENTRIES
LLUSER:	BLOCK NFILES	;STORE PPN PARR. WITH UFD AND UFD2 HERE
FULWHO:	BLOCK NFILES	;NON 0 ==> THIS GUY IS IN FAST MODE.  0==> display full info

FILES:	BLOCK NFILES	;BLOCK OF PARTIAL FILE NAMES,,UFD ENTRY NUMBER
	-1		;FOR END
EDITRR:	0		; ≠ 0  ==>  EDIT IN /R MODE.  SET BY EDITR, RESET IN EDITF
DELIS0:	BLOCK NFILES	;DELETE LIST, FILES TO BE FLUSHED WHEN EXITING.
	-1		;FIRST FILE NAME KEPT HERE, IN PAR. WITH ...
DELIS1:	BLOCK NFILES	; THIS, FILE EXTENSION,,UFD IDX NUMBER KEPT HERE.
	-1		;NOTE UFD INDXS ARE INTO CORE TABS, NOT DSK UFD
DELIS2:	BLOCK NFILES	;PPN TABLE FOR DELETE LIST
	-1
PDL:	BLOCK PDS
QPDL:	BLOCK QPDS	;Q PDL
UUOACS:	BLOCK 20

;UUO'S
	OPDEF GET	[1000,,]	;GET WORD FROM UFD CHAN
	OPDEF SGEN	[2000,,]	;STUFF STRING ONTO BP7
	OPDEF SPRINT	[3000,,]	;OUTPUT CONT. OF E TO BP7 IN RADIX AC
	OPDEF FLOOKU	[4000,,]	;LOOKUP ON FILC, BUT USE LUKDAT IF YOU CAN
	OPDEF REMOVE	[5000,,]	;REMOVE THIS FILE FROM CORE DATA
	OPDEF TYPE6	[6000,,]	;IDPB AC CHRS OF SIXBIT FROM E TO ASCII BP7
	OPDEF TTY6	[7000,,]	; "" "" TO THE TTY
	OPDEF SGENA	[10000,,]	;SGEN THAT SKIPS
;RANDOM OPDEFS
	OPDEF SAVE	[PUSH P,]
	OPDEF RETURN	[POP P,]
	OPDEF RECALL	[POP P,]

COMTAB:	;SWITCHES IN ALPHA ORDER CORR. TO DOTAB
	[ASCIZ /ABORT/]
	[ASCIZ /ALPHA SORT/]
	[ASCIZ /DEBUG MODE/]
	[ASCIZ /DELETE/]
	[ASCIZ /DATE SORT/]
	[ASCIZ /DSK MODE/]
	[ASCIZ /EDIT FILE/]
	[ASCIZ /EXAMINE FILE/]
	[ASCIZ /EXTENSION SORT/]
	[ASCIZ /F/]
	[ASCIZ /FAST MODE/]
	[ASCIZ /FOONLY/]
	[ASCIZ /FULL MODE/]
	[ASCIZ /HELP I NEED SOMEBODY, HELP NOT JUST ANYBODY/]
	[ASCIZ /K MODE/]
	[ASCIZ /LOOKUP CURRENT FILE/]
	[ASCIZ /OUTPUT/]
	[ASCIZ /PRINT A BIT OF THIS FILE/]
	[ASCIZ /R/]
	[ASCIZ /READONLY/]
	[ASCIZ /READWRITE/]
	[ASCIZ /REVERSE SORT/]
	[ASCIZ /SHOW DELETE LIST/]
	[ASCIZ /SIZE SORT/]
	[ASCIZ /SPOOL MY FILES, PLEASE/]
	[ASCIZ /UDP MODE/]
COMEND:
COMLEN←←COMEND-COMTAB+1
DOTAB:	ABORT	;ABORT DELETES TYPED SO FAR, BUT NOT RUN
	ALPHAS	;SORT BY FILE NAMES
	DEBGM	;DEGUG MODE
	RUNDEL	;RUN DELETE LIST, ACTUALLY DO DSK DELETES
	DATESR	;SORT BY FILE WRITE DATES
	DSKMOD	;EDIT DSK
	EDITF	;EDIT THE CURRENT FILE
	EDITR	;EXAMINE, EDIT THE CURRENT FILE IN /R MODE
	EXTSRT	;SORT IN ALPHA, FILE NAME AND EXT SWITCHED
	FFASTM	;FAST MODE, DONT DO LOOKUPS
	FFASTM	;ANOTHER WAY OF TYPING IT
	OUTDTA	;OUTPUT FILE DATA (AS IN OUTPUT) IN FOONLY MODE
	FFULM	;GET OUT OF FAST MODE, READ LOOKUPS
	HELPSW	;DISPLAY SWITCH HELP
	KMODC	;COMPLEMENT %KMODE
	LKPCF	;GET ALL THE DATA ON THIS RANDOM FILE, AND DISPLAY IT IN THAT WAY
	OUTDT	;OUTPUT ALL THE DIRECTORY INFORMATION TO GIVEN DEVICE
	PRIFIL	;PRINT A COUPLE OF LINES OF THIS FILE, NOT INCLUDING E DIRECTORY PG
	RDONLY	;ENTER READ ONLY MODE
	RDONLY	; "  "
	READW	;ENTER READWRITE MODE
	RVSRT	;COMPLEMENT THE ORDER OF THE FILES (A TO Z, OR Z TO A) ..
	SHOWU	;COMPLEMENT SHOW DELETE LIST/FILE DIRECTORY
	SZSRTS	;SORT FILES BY SIZE
	SPOOLR	;SPOOL ARG FILES FROM CURRENT
	UDPMOD	;EDIT UDP RATHER THAN DSK



MONTHS:	SGEN [ASCIZ /-Jan-/]
	SGEN [ASCIZ /-Feb-/]
	SGEN [ASCIZ /-Mar-/]
	SGEN [ASCIZ /-Apr-/]
	SGEN [ASCIZ /-May-/]
	SGEN [ASCIZ /-Jun-/]
	SGEN [ASCIZ /-Jul-/]
	SGEN [ASCIZ /-Aug-/]
	SGEN [ASCIZ /-Sep-/]
	SGEN [ASCIZ /-Oct-/]
	SGEN [ASCIZ /-Nov-/]
	SGEN [ASCIZ /-Dec-/]
;DMSWAP DMGO GO NODM GO2 RCYCLE RCYCL1

DMSWAP:	SIXBIT/SYS   DMDRD DMP   /
	0
	0

DMGO:	MOVEI B,0
	SKIPE FROME
	MOVEI B,1		;Start up DMDRD in RPG mode if we were
	MOVEM B,DMSWAP+3
	MOVEI B,DMSWAP
	SWAP B,
	JRST NODM
	
GO:	JRST .+3		;E STARTS AT +1
	 CLRBFI			;FLUSH TRASH FROM E'S INPUT BUFFER
	 SETOM FROME#		;AVOID THINKING ABOUT COMAND LINE
	MOVE P,[-PDS,,PDL-1]
	MOVEI F,		;ZERO ALL THE FLAGS
	SETO A,			;GETLIN LIKES -1
	GETLIN A		;TELL LUSER HE IS LUSING IFF NOT DISPLAY
TLNE A,40000		;DM'S USE ANOTHER PROGRAM
JRST DMGO
	TLNN A,20000!400000	;SKIP IF DD OR III
NODM:	TRO F,%TTY		;NOT DISPLAY
	TLNE A,(<SETZ>)		;direct IF III, skip IF DD
	TRO F,%GETTY		;ONE MEANS III
	MOVEI A,
	DSKPPN A,
	MOVEM A,LUSER		;DEFAULT TO SELF
	MOVE A,[JSR UUOH]
	MOVEM A,41
	PUSHJ P,RTMPC		;READ THE TEMP CORE FILE

	SKIPE FROME		;DONT THINK ABOUT COMMAND LINE IF WE ARE HERE FROM E
	JRST RCYCLE
	PUSHJ P,RSCAN		;FIGURE OUT WHO CALLED US AND SCAN TILL END OF
	JRST SETMASK	;THIS GUY WILL LISTEN TO TTY
	TRZ F,%START	;WE SHOULD BE OUT OF TOWN BY SUNDOWN
	SETZM FROME	;STUFF MONTIOR READ
COMMENT ⊗ Old Rescan
	RESCAN	;GET THE COMMAND LINE BACK
GO2:	INCHRS A
	JRST RCYCLE	;THAT'S IT, NO SWITCHES
	CAIE A,";"
	JRST GO2	;WELL, TRY THE NEXT CHR
	TRZ F,%START	;THIS MEANS WE ARE ONLY PARTIALLY RUNNING, BE CAREFUL
	JRST SETMASK; THIS WILL TRY TO GET A FILE NAME FOR MASK, AND
		;PASS THE BUCK TO RPPN OR SWITCH IF IT NEEDS TO.
	⊗
RCYCLE:	TRZN F,%RRUFD	;WE GOT HERE FROM RPPN ETC. SO RUN DELETE LIST FIRST
	JRST RCYCL1
	PUSHJ P,USTATS		;USE STATISTICS HACK
	SKIPE DELIS0
	OUTSTR [ASCIZ /Running delete list - /]
	PUSHJ P,XITING
RCYCL1:	TRNN F,%TCORE	;SKIP OVER THESE RESETS IF WE GOT THEM SET UP FRM TMPCOR FILE
	SETZM CURFIL		;SET CURRENT FILE CELL TO FIRST FILE
	TRZN F,%TCORE
	SETZM DIPFIL		;SET FIRST FILE TO BE DISPLAYED TO FIRST FILE
	;FALL THRU TO NEXT PAGE
COMMENT ⊗ Main loop.  Display, Decode, Execute ⊗
	;FALLS THRU
	PUSHJ P,GETSET		;INITS AND SET UP DD PLEASE
	TRNN F,%START	;PRINT THIS MESSAGE IF THIS IS THE FIRST TIME THRU
	outstr [asciz ∧
DIRED.6   Type ? for Help  [Startup faster. Reads new UFDs]∧]
	TRO F,%START	;WE ARE FULLY STARTED, DIRECT IF FIRST TIME THRU
CYCLE:	PUSHJ P,ZCLEAR
	PUSHJ P,REAUFD		;READ THE UFD, RETURN IN A # OF FILES IN DIR
	HRRZM A,TFILE↔SUBI A,1↔HRRZM A,TFILE1
SCYCLE:	PUSHJ P,SORT
FCYCLE:	PUSHJ P,PUTUP		;PUT UP SCREEN FROM DIPFIL, POINT AT CURFIL
FFCYCL:	PUSHJ P,ARROW		;PUT ARROW UP IN C 1, RETURN HERE FOR FASTEST RE-DSP
OCYCLE:	SNEAKS			;DON'T OK ME, IM TALKING TO YOU!
	JRST [ OUTSTR [ASCIZ /OK /]  ↔  JRST .+2]
	OUTCHR [" "]
RIHANG:SETZM ARGSGN		;INDICATE SIGN IS +
	SETZM ARGF		;INDICATE NO ARG AVAILABLE
	SETZM ARG		;AND SET ARG TO ZERO

IHANG:	INCHRW A		;CAN'T THINK OF ANYTHING BETTER TO DO NOW
	ISTHIS (A,tjum,T,T,F,T)	;show arg*4 mose lines at top
	ISTHIS (A,JJUMP,J,T,F,T)	;JUMP GOES TO WJMP (αJ OR αβJ)
	ISTHIS (A,bjum,B,T,F,T)	;show arg*4 more lines at bottom
	ISTHIS (A,SETMAS,M,T,F,T)	;αβM IS READ A MASK
	ISTHIS (A,ANDJUM,∧,T,F,T)	;MOVE CURSOR TO ARGTH LINE FROM TOP
	ISTHIS (A,ORJUM,∨,T,F,T)	; "	" BOTTOM
	ISTHIS (A,LJUM,L,T,F,T)		;ARGTH LINE
	CAIN A,"/"
	JRST SWITCH
	CAIN A,"["		;IS THIS GUY TRYING TO GIVE US A PPN?
	JRST RPPN
	CAIN A," "
	JRST LINE
	ISTHIS (A,UEXIT,E,T,T,T)	;αβE IS EXIT (ALSO αE OR βE)
	ISTHIS (A,WDOWN,W,T,F,T)	;WINDOW DOWN?
	CAIN A,14	;FORM IS SAME AS  ↑
	JRST WDOWN
	CAIN A,13	;VT IS UP
	JRST WUP
	TRNN F,%DEBUG		;βV IS DEBUG MODE IS DEFINED
	JRST DECD1
	ISTHIS (A,CYCLE,V,F,T,F);βV IS RE  READ UFD IN DEBUG MODE
DECD1:	ISTHIS (A,<[	PUSHJ P,DPYINI	;SET UP DISPLAY
			JRST FCYCLE	;NOW PUT UP DISPLAY
			]>,V,T,F,T)	;RE DRAW SCREEN
	CAIN A,600+"≡"	;GO TO DDT?
	JRST UDDT
	CAIL A,600+"0"
	CAILE A,600+"9"
	JRST .+2		;NOT A NUMBER
	JRST ARGIN		;GOBBLE THIS DIGIT
	CAIL A,200+"0"
	CAILE A,200+"9"
	JRST .+2		;FOR SURE NOT A NUMBER
	JRST ARGIN		;AND WHERE'S YOUR POINT?
	CAIE A,600+"-"		;IS THIS A -?
	CAIN A,200+"-"
	JRST ARGNEG
	CAIE A,600+"∞"		;IS THIS GUY TRYING TO TELL US SOMETHING?
	CAIN A,200+"∞"
	JRST ARGINF		;I GUESS SO
	ISTHIS (A,DELETE,D,T,F,T)	;A DELETE?
	CAIN A,"?"		;HUH?
	JRST HELP		;SET THE TURKEY FLAG
	CAIE A,600+">"
	CAIN A,200+">"		;DOWN?
	JRST DN
	CAIE A,600+"<"		;UP?
	CAIN A,200+"<"
	JRST UPJ
	CAIN A,15	;CR
	JRST DNO
	CAIE A,200+"≥"	;DOWN ON α≥ 
	CAIN A,600+"≥"	;DOWN ON αβ≥ TOO
	JRST DNE
	ISTHIS(A,UPO,U,T,F,T)
	CAIE A,200+177  ;correction by REF 9/16/77 was 200+""
	CAIN A,177	;correction by REF 9/16/77 was ""
	JRST UPO
	CAIN A,600+177
	JRST UPO
	CAIE A,200+"≤"
	CAIN A,600+"≤"	;THIS TOO
	JRST UPE
	;CONTINUED ON OTHER SIDE OF COMMENT
	CAIE A,12	;LF IS NO OP
	JRST HUH
	TRNN F,%START	;UNLESS THIS IS THE LF FROM MONITOR COMMAND LINE
	JRST RCYCLE
	JRST RIHANG
HUH:	OUTSTR [ASCIZ /  Unknown command - /]
	TRZE A,200	;DIRECT IF CONTROL BIT ON IN BAD COMMAND TYPED
	OUTSTR [ASCIZ /<CONTROL>/]
	TRZE A,400	;DIRECT IF META BIT ON IN BAD COMMAND
	OUTSTR [ASCIZ /<META>/]
	XCT CHRS(A)
;	OUTCHR A
	OUTSTR [ASCIZ /
/]↔	JRST RIHANG


CHRS:	0
	FOR ZZ←"↓","λ",1 <
	OUTCHR [ZZ]
	>
	OUTSTR [ASCIZ /TAB/]
	OUTSTR [ASCIZ /LF/]
	OUTSTR [ASCIZ /VT/]
	OUTSTR [ASCIZ /FF/]
	OUTSTR [ASCIZ /CR/]
	FOR ZZ←"∞","∨",1 <
	OUTCHR [ZZ]
	>
	OUTSTR [ASCIZ /SPACE/]
	FOR ZZ←"!","|",1 <
	OUTCHR [ZZ]
	>
	OUTSTR [ASCIZ /ALT/]
	OUTCHR ["}"]
	OUTSTR [ASCIZ /BS/]
	JRST 4,RIHANG
COMMENT ⊗ Switch Decoder ⊗
TO←←D
BO←←E
SWITCH:	MOVE A,[440700,,(I)]	;I WILL HAVE PTR TO TEXT FROM COMTAB VIA D OR E
	MOVEM A,BP7
	MOVEI TO,	;CLOSE IN ON COMMAND FROM THE TOP
	MOVEI BO,COMLEN	;CLOSE IN ON COMMAND FROM THE BOTTOM OF COMMAND LIST

SWL0:	IBP BP7
SWL1:	INWAIT		;GET A CHR.  IF IT IS A / DONT REMOVE IT FROM THE INPUT BFR,
	SNEAKS A,	; AND PRETEND IT WAS A CR (END OF COMMAND)
	 JRST 4,.
	CAIE A,"["	;DO THE SAME FOR...
	CAIN A,"/"	;SLASH?
	JRST SWCR	;YES, BUT LEAVE IT THERE SO TOP LEVEL COMMAND DECODER WILL
			;CALL US AGAIN AFTER THE SWITCH JUST TYPED DOES ITS THING
	INCHWL A	;WASN'T  /, GET THE CHR OUT OF BUFFER
	CAIN A,"["	;ARE WE BEING FALSELY ACCUSED OF READING A PPN?
	JRST RPPN	;YES, PASS THE BUCK
	CAIE A,15	;CR
	JRST SWNM
;	SNEAKS A,	;CHECK TO SEE IF THIS IS A LF AFTER THE CR
;	JRST SWCR
;	CAIN A,12
;	INCHRW		;YEP, IT WAS A LF, REMOVE IT
SWCR:	CAMN D,E	;IS THE COMMAND DECODED SO FAR AMBIG.?
	JRST @DOTAB(D)	; NOPE, THEY ARGEE ON COMMAND TO RUN
	MOVEI B,	;BEFORE WE DECIDE THIS IS AMBIG, SEE THAT IT IS NOT AN
	MOVE I,COMTAB(D);ARGUMENT BETWEEN COMMANDS LIKE "BAG" AND "BAGS"
	LDB B,BP7
	JUMPE B,@DOTAB(D); YEP, THE ASCII 0 WAS FOOLIN US
	JRST AMBH	;BARF AT LUSER

SWNM:	CAIL A,141
	CAILE A,172
	JRST .+2
	SUBI A,40
ROARDN:	MOVE I,COMTAB(TO)
	LDB B,BP7
	CAMN A,B
	JRST ROARUP
	CAML TO,BO
	JRST BADCHR
	AOJA TO,ROARDN
ROARUP:	MOVE I,COMTAB(BO)
	LDB B,BP7
	CAMN A,B
	JRST SWL0
	CAMN TO,BO
	 JRST 4,.
	SOJA BO,ROARUP
BADCHR:	OUTSTR [ASCIZ /I Don't know that switch.
/]↔	CLRBFI
	JRST BADCH1	;ABORT READING OF SWITCH
BADCH1:	TRNE F,%START	;ARE WE FULLY STARTED OR READING COMMAND LINE SW'S
	JRST RIHANG	;FULLY STARTED
	EXIT		;NO, READING INITAL SWS
AMBH:	OUTSTR [ASCIZ /Ambiguous Switch.
/]
	CLRBFI		;FLS INPUT BUFFER 
	JRST AMBH1
AMBH1:	TRNE F,%START	;ARE WE READING INITIAL SW'S OR ARE WE RUNNING
	JRST RIHANG	;WE ARE RUNNING
	EXIT		;NOT RUNNING
COMMENT ⊗ Cursor up and down ⊗

define down (a0,a1,a2,a3,a4) < ; 1→LOOP,2→END
a0:	ARGET D,1,a4	;GET ARG INTO D, DEFAULT IS 1
	MOVE A,CURFIL	;GET CURRENT SCREEN SETTINGS FOR MUNGING AROUND WITH
	MOVE B,DIPFIL
a1:	SOJL D,a2	;ITERATE ON PROCESS ARG TIMES
	ADDI A,a3	;CR MEANS INCR. CURFIL BY ONE
	CAMLE A,TFILE1	;DIRECT IF THIS HAS CAUSED US TO FALL OF THE END OF DIRECTORY
	JRST [	MOVE A,TFILE1 	;THEN PATCH IT SO WE ARE JUST AT THE END OF DIR
		MOVE B,TFILE1	;THEN GIVE A2 REDICULOUS DIPFIL, IT WILL FIX IT
		JRST A2]; JUST PRETEND HE WENT TO THE LAST LINE INSTEAD
	CAIg A,NLINES-1-GLTP(B) ;skip IF CURFIL IS OFF END OF SCREEN, BUMP DIPFIL TO WIN
	JRST A1		;HAPPY, EXIT, BUT LOOP AGAIN IF ARG GIVEN WANTS US TO
	ADDI B,GLTBY   ;CONTINUE MOVING DOWN IN DIRECTORY UNTIL WE HAVE SATISFIED GLITCHP
	JRST .-3	; "  "               
a2:	MOVEM A,CURFIL	;SAVE OUR CHANGES TO DISPLAY INFORMATION
	MOVE C,B
	ADDI C,NLINES
	CAMLE C,TFILE
	SKIPG B
	SKIPA
	SUBI B,1
	CAMN B,DIPFIL	;HAVE WE CHANGED THE WINDOW? (SKIP IF T)
	JRST FFCYCLE	; WE ONLY HAVE TO DISPLAY NEW ARROW, NOT NEW WINDOW
	MOVE A,TFILE	;CHECK TO SEE IF GLITCH HAS GONE TO FAR, ONLY IF THERE
	CAIGE A,NLINES	;ARE ENOUGH FILES TO FILL AN ENTIRE SCREEN
	HRRM A,.+1
;       JRST .+4
       SUBI A,NLINES
	CAIGE A,(B)	;SKIP IF DIPFIL IS SMALL ENOUGH
	MOVE B,A	;USE LARGEST DIPFIL THAT GETS A WHOLE SCREEN
	MOVEM B,DIPFIL	;THE WINDOW ON THE WORLD IS DIFFENT, SAVE IT
	MOVEI NLINES
       HRRM .-5
	JRST FCYCLE	;AND PUT UP NEW DISPLAY FROM THE TOP
>
define up (a0,a1,a2,a3,a4,A5) < ;1→LUP,2→L (BUMP WINDOW),3→END
a0:	ARGET D,1,A5
	MOVE A,CURFIL
	MOVE B,DIPFIL	;GET DISPLAY INFORMATION TO MUNG AROUND WITH
a1:	SOJL D,UPOEND	;DO THIS ARG TIMES
	SUBI A,a4	;MOVE UP
	CAIGE A,		;DIRECT IF WE HAVE MOVED PAST BEGINING OF DIRECTORY
	JRST [	MOVEI A,	;THEN PRETEND WE WERE AT THE TOP AND EXIT
		MOVEI B,	;PRETEND WE ARE AT TOP
		JRST A3]	;PRETEND IT WAS THE FIRST INSTEAD
a2:	MOVE C,A↔SUB C,B;PUT CURFIL RELATIVE TO TOP OF SCREEN IN C
	CAIL C,GLTP	;SKIP IF WE NEED TO GLITCH BECAUSE TO CLOSE TO TOP OF SCN
	JRST A1		;DO ENTIRE THING ARG TIMES, OTHER THAN THAT, THIS IS EXIT
	SUBI B,GLTBY	;KEEP BUMPING B (WINDOW) TILL GLITCHP IS HAPPY
	JRST A2
a3:	MOVEM A,CURFIL	;SAVE OUT MUNGAGE ON CURFIL
	CAIGE B,	;IF DIPFIL IS NEG
	MOVEI B,	;CALL IT ZERO, IT MEANS WINDOWING OVERSHOT BEG WHILE ADJUSTN
	CAMN B,DIPFIL	;HAVE WE CHANGED THE WINDOW
	JRST FFCYCLE	;NO, DONT NEED TO SAVE THIS, FAST DISPLAY
	MOVEM B,DIPFIL
	JRST FCYCLE
>
DNO:	TRO F,%NOOK
	DOWN DNOZ,DNOLUP,DNOEND,1,UPO
	DOWN DN,DNLUP,DNEND,4,UPJ
	DOWN DNE,DNELUP,DNEEND,<NLINES/2>,UPE

UPO:	TRNN F,%START		;SKIP IF WE HAVE DONE PROPER INIT STUFF
	JRST RIHANG		;ASSUME THIS WAS THE CR AT THE END OF MONITOR COMMAND
	;FALL THRU TO UPOQ
	UP UPOQ,UPOLUP,UPO1,UPOEND,1,DNO
	UP UPJ,UPLUP,UP1,UPEND,4,DN
	UP UPE,UPELUP,UPE1,UPEEND,<NLINES/2>,DNE

;JMP:	MOVE A,CURFIL	;αβJ COMMAND
Comment ⊗ Window up and down ⊗
WDOWN:	move a,curfil	;arrow
	move b,dipfil	;top of screen
	arget d,1,WUP	;arg in d, default 1, wup if negative
	subi d,1	;jump arg-1 windows
	imuli d,nlines-1
	addi b,(d)
	move c,tfile	;tfile-nlines is max dipfil
	subi c,nlines
	caige c,
	movei c,
	caile b,(c)	;direct if new dipfil gr max
	move b,c	; use max
	move d,b	;new arrow is bottom line of this window
	addi d,nlines	;plus nlines
	camle d,tfile	;(correct if off end)
	move d,tfile
	movei a,-1(d)	;-1 is new arrow
	addi b,nlines-1	;choose final window
	caile b,(c)	;direct if new dipfil gr max
	move b,c
	movem a,curfil
	movem b,dipfil
	jrst fcycle
	
wup:	move a,curfil
	move b,dipfil
	arget d,1,wdown
	subi d,1
	imuli d,nlines-1
	subi b,(d)
	caige b,
	movei b,
	move a,b
	subi b,nlines-1
	caige b,
	movei b,
	movem a,curfil
	movem b,dipfil
	jrst fcycle

jjump:	skipe argf
	skipe arg
	jrst .+2
	jrst jjum3
	skipe argsgn	;skip if no sign
	jrst jjum2
	move a,tfile
	subi a,nlines
	caige a,
	movei a,
	move b,curfil
	caile b,(a)
	move b,a
	skipe argf
	pushj p,jjum1
	movem b,dipfil
	jrst fcycle
jjum1:	move a,arg
	add a,dipfil
	caile a,(b)
	move a,b
	move b,a
	popj p,
jjum2:	move a,curfil
	subi a,nlines-1
	caige a,
	movei a,
	skipn argf
	movni b,nfiles
	skipe argf
	movn b,arg
	add b,dipfil
	caige b,(a)
	move b,a
	movem b,dipfil
	jrst fcycle
jjum3:	jrst fcycle	;jump middle one of these days

tjum:	;make arg*four more lines visable at the top
	arget (a,1,bjum)
	imuli a,4
	move b,dipfil
	subi b,(a)
	caige b,	;off the top
	movei b,
	movem b,dipfil
	addi b,nlines-1	;is lowest allowed arrow location
	camge b,curfil
	 movem b,curfil
	jrst fcycle
bjum:	;make arg*four more lines visable at the bottom
	arget (a,1,tjum)
	imuli a,4
	add a,dipfil	;new desired dipfil
	move b,tfile
	subi b,nlines	;max dipfil value for full screen
	caige b,	;file list shorter than screen
	 movei b,
	caile a,(b)	;proposed dipfil too big?
	 move a,b
	movem a,dipfil
	camle a,curfil	;backed up over cursor?
	 movem a,curfil
	jrst fcycle

andjum:	;∧ ;move cursor to argth line from top of window
	arget (a,1,orjum)
	caile a,nlines
	 movei a,nlines
	subi a,1
	add a,dipfil
	movem a,curfil
	jrst fcycle
orjum:	;∨ ;move cursor to argth line from bottom of window
	arget (a,1,andjum)
	move b,tfile
	caile b,nlines
	 movei b,nlines
	caile a,(b)
	 movei a,(b)
	movn a,a
	addi a,(b)
	add a,dipfil
	movem a,curfil
	jrst fcycle

ljum:	;move cursor to argth line
	arget (a,1,lljum)
	caig a,
	 movei a,1
	camle a,tfile
	 move a,tfile
	subi a,1
ljum0:	movem a,curfil
	move b,dipfil
	addi b,nlines-1
	caig a,(b)	;cursor off bottom?
	camge a,dipfil	;cursor off top of current window?
	 jrst ljum1
	jrst fcycle
ljum1:	subi a,nlines/2
	move b,tfile
	subi b,nlines	;max dipfil value for full screen
	caile a,(b)
	 move a,b
	caige a,
	 movei a,
	movem a,dipfil
	jrst fcycle
lljum:	arget (a,1,ljum)
	movn a,a
	add a,curfil
	caige a,
	 movei a,
	jrst ljum0
COMMENT ⊗ Enter E on current file ⊗
EDITR:	SETOM EDITRR		;EDIT IN /R MODE
EDITF:	
	SKIPN TFILE		;ARE THERE ANY FILES IN THE UFD
	JRST EDITNF		;NO FILE TO EDIT
	SKIPE DELIS0		;TYPE MSG. IF THERE IS AT LEAST 1 FILE TO DELETE
	OUTSTR [ASCIZ /Running your delete list.../]
	PUSHJ P,XITING	;RUN DELETE LIST, AND ANYTHING ELSE THAT MAY BE STUCK IN THERE
	TRNN F,%GETTY	;ON A DD..
	PUSHJ P,ZCLEAR	;CLEAR THE SCREEN
	PUSHJ P,WTMPC	;WRITE A TEMP CORE FILE SO WE CAN RESTRT
	SETZM DIRLIN		;ZERO DIRLIN SO PTWRS9 KNOWS WHERE TO STOP
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[441100,,DIRLIN]	;BYTE POINTER FOR PREPATING COMMAND
	MOVEM A,BP7
	MOVEI A,600	;CALL
	IDPB A,BP7
	IDPB A,BP7
	SGEN [ASCIZ /R E;↓/]   ;USE R E, NOT ET SO IT DOESNT CLOBBER LUSERS E TMPCOR
	TYPE6 6,LOSS0	;NOW TELL E THE DEVICE NAME
	SGEN [ASCIZ /↓:↓/]	;THE 2ND ↓ IS FOR THE FILE NAME, COMMING UP
	MOVE A,CURFIL	;FIND OUT WHAT FILE THIS GUY WANTS TO EDIT
	MOVE A,FILES(A)
	CAMN A,[-1]	;-1 SHOULD ONLY BE THERE IN THE CASE WHERE THERE ARE NO FILES
	 JRST 4,.	;FILE DOES NOT EXIST???
	MOVE B,UFD(A)	;THIS WILL BE FILE NAME ONE
	TYPE6 6,B
	SGEN [ASCIZ /↓.↓/]
	MOVE B,UFD2(A)	;GET THE EXT OF THIS FILE
	TYPE6 3,B
	SGEN [ASCIZ "↓["]
	MOVE B,LLUSER(A);GET PPN OF THE FILE TO BE EDITED
	MOVE C,[440600,,B]
REPEAT 3,{ILDB D,C ↔ ADDI D,40 ↔ IDPB D,BP7}
	SGEN [ASCIZ /,/]
REPEAT 3,{ILDB D,C ↔ ADDI D,40 ↔ IDPB D,BP7}
	SGEN [ASCIZ "]"]
	ARGET A,1,<[MOVM A,A↔JRST EDIT1]>
EDIT1:	SGEN [ASCIZ "/"]	;AND TELL E TO START UP ON THAT PAGE
	SPRINT =10,A
	SGEN [ASCIZ /P/]	;FOR PAGE , I.E. ET ... /69P
	SKIPE EDITRR	;EDIT IN /R MODE?
	SGEN [ASCIZ "/R"]
	SETZM EDITRR
	SPRINT 8,[-3]	;PUT A CR, W/O LF IN STRING TO GET IT GOING
	OUTSTR [ASCIZ /



/]	;CLEAR OLD NONSENSE
	DPYPOS -1069	;POSITION POP OF END OF SCREEN SO THIS IS NOT VISABLE
	PTWRS9 [0↔DIRLIN]	;SHOULD RUN E ON THIS FILE
	JRST 4,.	;WE SHOULD NOT BE RUNNING HERE
EDITNF:	OUTSTR [ASCIZ /
There is no file to edit.
/]↔	JRST RIHANG
COMMENT ⊗ Delete  HAS BEEN DELETED
	THIS CRAPP IS UNUSED !!!

DELETE:	PUSH P,A↔PUSH P,B↔PUSH P,C↔PUSH P,D↔PUSH P,E
	SKIPE ARGF	;IS THERE AN ARG?
	SKIPA A,ARG
	MOVEI A,1
	SKIPE ARGSGN	;NEG ARG MEANS UNDELETE ONE FILE
	JRST UNDEL
	MOVE B,CURFIL
DELLOP:	PUSH P,B ;B IS USED FOR DELETING SCR FILE, AND FILES POINTER IN LOOP
	MOVE B,[['......'↔'...   '↔0],,DELBLK]
	BLT B,DELBLK+2	;DELETE OLD SCRATCH FILE IF IT EXISTS
	MOVE B,LUSER	;SET UP PPN TOO
	MOVEM B,DELBLK+3
	MOVEM B,RENBLK+3	;RENAME WANT THIS PPN ALSO
	SETZM RENBLK	;SO RENAME WILL DELETE IT
	LOOKUP FIL,DELBLK
	 JRST DELPRO	;IF IT DOES NOT EXIST THAT IS FINE, DONT DELETE IT 
	RENAME FIL,RENBLK
	 JRST 4,.	;HUH?
DELPRO:	CLOSE FIL,	;SCRAM
	POP P,B	;B USED FOR DELETING SCR FILE
;A IS LOOP COUNTER, SOURCE IS ARG TO αβD.
;B HAS IDX INTO FILES (0-* AS FILES APPEAR ON SCREEN) AOSED EACH TIME THRU
	MOVE C,FILES(B) 		;LOOP DELETING FILE IN A (WHICH IS IDX→FILES
	CAMN C,[-1]	;DOES THIS FILE REALLY EXIST, OR HAVE WE OVERSHOT
	JRST DELDON	;DONE, NO MORE FILES TO FLUSH
	MOVEM C,OLDFIL	;SAVE UFD POINTER INCASE THIS FILE GETS UNDELETED
	MOVE D,UFD(C)	;GET FIRST FILE NAME
	MOVEM D,DELBLK
	MOVE D,UFD2(C)	;GET EXT
	MOVEM D,DELBLK+1
	MOVE D,LUSER	;GET PPN WE ARE DEALING WITH
	MOVEM D,DELBLK+3
	LOOKUP FIL,DELBLK	;FILE WE ARE DELETING
	 JRST 4,.
	MOVS D,DELBLK+3		;TAKE THIS NUMBER OF WORDS OFF OF TOTAL
	ADDM D,WORDS		;D CONTIANS -NUMBER  OF WORD 
	SOS TFILE ↔ SOS TFILE1	;DECREMENT LOCS CONTAINING NUMBER OF FILES
	MOVE D,['......']	;RENAME TO THIS WHEN YOU DELETE, SO IT CAN BE RECOVD
	MOVEM D,RENBLK
	MOVSI D,'...'	;THIS EXT
	MOVEM D,RENBLK+1
	MOVE D,DELBLK+2	;GET OLD PRO, MODE, DATE, ETC
	MOVEM D,RENBLK+2;KEEP THE SAME
	MOVE D,LUSER
	MOVEM D,RENBLK+3
	RENAME FIL,RENBLK
	 JRST 4,.
	REMOVE B	;REMOVE THIS FILES FROM CORE DATA
	SOJG A,DELLOP
	JRST DELDON	;DONE, WE HAVE DELETED ALL WE WERE TOLD TO
UNDEL:	MOVE A,DELBLK	;GET NAME OF FILE LAST DELETED
	CAMN A,['......']
	JRST UNDEL2	;LAST FILE DELETED HAS ALREADY BE UNDELETED
	MOVEM A,RENBLK	;PREPARE TO RECOVER IT
	MOVE A,DELBLK+1	;GET EXT
	MOVEM A,RENBLK+1
	MOVE A,['......']	;FOR LOOKUP, TO RECOVER
	MOVEM A,DELBLK
	MOVSI A,'...'
	MOVEM A,DELBLK+1
	MOVE A,LUSER
	MOVEM A,DELBLK+3
	OUTSTR [ASCIZ /
Undeleting File /]↔pushj p,filprn
	OUTSTR [ASCIZ / - /]
	LOOKUP FIL,DELBLK	;THE SCR FILE IS BEING RENAMED TO LAST FILE DELTED
	 JRST 4,.
	MOVS A,DELBLK+3		;THIS IS THE -SIZE OF THE FIL IN A, ADD FILE SIZE
	SUBM A,WORDS		; TO WORD COUNT (BY SUBTRACTING, WE HAVE -WORD CNT)
	AOS TFILE ↔ AOS TFILE1	;INCREMENT LOCS WITH NUMBER OF FILES
	RENAME FIL,RENBLK
	 JRST 4,.
	JRST NDELDON
UNDEL2:	OUTSTR [ASCIZ /There is no file to undelete.
/]↔	POP P,E↔POP P,D↔POP P,C↔POP P,B↔POP P,A
	JRST RIHANG
NDELDO:		;NOW MUST RECONSTRUCT FILES TABLE AND LOOKDAT TABLE
	MOVEI A,	;LOOK FOR A FREE ENTRY IN FILES TABLE
NDELD1:	MOVE B,FILES(A)	;GET THIS ONE
	CAME B,[-1]	;SKIP IF WE HAVE FOUND ONE
	AOJA A,NDELD1	;TRY NEXT ENTRY
	MOVE B,OLDFIL	;GET OLD UFD POINTER
	MOVEM B,FILES(A);RE-INSTALL IT IN FILES TABLE
	MOVE B,[RENBLK,,UFDIN]	;BLT RECOVERED FILE NAME INTO LONG LOOKUP BLOCK
	BLT B,UFDIN+1	;ONLY THE FILESNAMES ARE LOOKED AT BY FLOOKUP
	FLOOKUP		;WILL ADD LOOKUP DATA TO LUKDAT
	 JRST 4,.
	POP P,E↔POP P,D↔POP P,C↔POP P,B↔POP P,A↔JRST SCYCLE
DELDON:	PUSHJ P,ZCLEAR	;CLEAR DIRECTORY AREA OF SCREEN
	POP P,E↔POP P,D↔POP P,C↔POP P,B↔POP P,A
	JRST FCYCLE
FILPRN:	PUSH P,A↔PUSH P,B
	MOVE A,[440600,,RENBLK]
REPEAT 6,{ILDB B,A↔ADDI B,40↔OUTCHR B}
	OUTCHR [11]
	MOVE A,[440600,,RENBLK+1]
REPEAT 3,{ILDB B,A↔ADDI B,40↔OUTCHR B}
	POP P,B↔POP P,A↔POPJ P,

		THIS CRAP IS NOT USED !!!!


⊗
COMMENT ⊗ New Delete System ⊗
DELETE:	ARGET A,1,UNDEL		;PUT REPEAT ARG IN A, DEFAULT IS 1, NEGATIVE MEANS UNDEL
	TRNE F,%DDELS		;DIRECT IF WE ARE DISPLAYING DELETE LIST
	JRST DELR		;DELETE FROM DELETE LIST
DELOOP:	SOJL A,DELDON		;ARG TIMES ON THE FOLLLOWING
	MOVEI B,		;FIND FIRST FREE SLOT IN DELETE LIST
DELL1:	MOVE C,DELIS0(B)	;0 IN WORD OF DELIS0 IS FREE SLOT, -1 IS LOSE
	CAIN C,
	JRST DELE1		;WIN, FOUND EMPTY SLOT
	CAMN C,[-1]		;HAVE WE HIT ROCK BOTTOM IN DELETE LIST?
	JRST FATL06		;YEP
	AOJA B,DELL1		;TRY NEXT SLOT IN DELETE LIST
DELE1:	;A NOW IS LOOP COUNTER, B IS FREE SLOT IN DELETE LIST
	MOVE C,CURFIL		;SO, WHAT IS THIS THE LUSER WANTS US TO FLS?
	MOVE D,FILES(C)		;PICK UP UFD IDX FOR FILE TO FLS
	CAMN D,[-1]		;IS THIS FILE UNDELETEABLE (DOES NOT EXIST)
	JRST DELDON		;YES, NO USE RUNNING THRU THIS SILLY LOOP...
	MOVE C,UFD(D)		;GET FIRST FILE NAME FROM UFD OF FILE TO FLS
	MOVEM C,DELIS0(B)	;STUFF THIS IN FREE CELL IN DELETE LIST
	MOVEM C,UFDIN		;FOR CHECK OF THE 'COPY' DELETE PROTECT BIT
	MOVE C,LLUSER(D)	;GET THE PPN
	MOVEM C,DELIS2(B)
	MOVEM C,UFDIN+3
	MOVE C,UFD2(D)		;GET THE EXT OF FILE TO FLS
	MOVEM C,UFDIN+1
	HRR C,D			;CLOBBER RH WITH IDX INTO UFD
	MOVEM C,DELIS1(B)	;AND PUT IT IN DELETE LIST
	FLOOKUP		;CHECK THE 200 BIT OF PRO. KEY, IF ON ASK USER IF HE
	 JRST 4,.	;REALLY WANTS TO DELETE THIS FILE.  ALWAYS SKIPS.
	MOVE C,UFDIN+2	;PRO IS IN HIGH 9. OF THIS
	TLNE C,200000
	JRST DELQU	;ASK USER IF HE REALLY MEANS IT
DELQR:	SOS TFILE ↔ SOS TFILE1	;DECREMENT COUNTERS OF NUMBER OF FILES IN THIS UFD
	REMOVE CURFIL		;REMOVE FILE JUST PUT IN DELETE LIST FROM CORE DATA
	MOVE C,CURFIL		;SEE IF WE JUST DELETED THE LAST THING ON THE SCREEN
	CAME C,TFILE		;SINCE BOTH WERE JUST DECRMD., ARE WE NOW POINTING AT STARS?
	JRST DELOOP		;LOOP ON THIS ARG TIMES
	JUMPE C,DELOOP
	SOS CURFIL		;YEP, CAUSE IT TO POINT AT FILE ABOVE,
		;AND FALL THRU TO DELDON, NO MORE TO DELETE NO MATTER WHAT ARG SAYS
DELDON:	JRST FCYCLE
DELQU:	OUTSTR [ASCIZ /
Do you really want to delete /]
	TTY6 6,DELIS0(B)	;PRINT THE FIRST FILE NAME
	OUTSTR [ASCIZ /  /]
	TTY6 3,DELIS1(B)	;PRINT THE EXT
	OUTSTR [ASCIZ / [/]
	TTY6 6,DELIS2(B)
	OUTSTR [ASCIZ /] ?/]
	INCHRW C		;C WAS FREE WHEN I WROTE THIS
	OUTSTR [ASCIZ /
/]↔	CAIE C,"Y"
	CAIN C,"y"
	JRST DELQR	;HE SAID SO...
	OUTSTR [ASCIZ /Spared.../]
	SETZM DELIS0(B)	;UNDO THE DAMAGE WE HAVE DONE TO THE DELETE LIST
	SETZM DELIS1(B)
	SETZM DELIS2(B)
	SOJL A,DELDON	;AS IF WE WERE TOP OF ARG<DELETE> LOOP, BUT DONT MAKE
		;US LOOK FOR SLOT, WE HAVE ONE NOW.
	AOS CURFIL	;GO TO NEXT FILE, IF WE HAVE OVERSHOT FILES, DELE1 WILL KNOW
	JRST DELE1

DELR:	;TAKE GUYS OUT OF DELETE LIST
	MOVE D,(A)
	MOVE A,CURFIL	;THIS IS THE ONE TO FLUSH
DELRL:	SOJL D,SCYCLE
	SKIPN B,DELIS0(A)
	JRST SCYCLE	;SEEM TO BE THRU, HIT AN EMPTY CELL
	PUSHJ P,INSERT	;INSERT THE DELIS FILE INDICATED BY A INTO FILES TABLE
	MOVEM B,UFDIN	;WE WILL BE DOING A LOOKUP HERE
	MOVE B,DELIS1(A);WE ARE INTERESTED IN THE EXT. STUFFED IN HERE
	MOVEM B,UFDIN+1
	MOVE B,DELIS2(A);THE PPN
	MOVEM B,UFDIN+3
	FLOOKUP	
	 JRST 4,.
	MOVS B,UFDIN+3	;GET THE -SWAPPED WORD COUNT, UNSWAPPED
	MOVN B,B	;GET WORD COUNT
	ADDM B,WORDS	;BUMP THE WORD COUNT 
	AOS TFILES	;TELL THE WORLD THERE ARE MORE FILES, BUT TFILE IS
		;HIDDEN IN TFILES
	MOVE B,A
	FIXGAP (B,DELIS0,NFILES,1)		;WIPE OUT ENTRY POINTED TO BY B
	SETZM DELIS0+NFILES-1		;THIS GOT A -1 FROM END OF TAB, IT WANTS 0
	MOVE B,A
	FIXGAP (B,DELIS1,NFILES,1)		;BY PRETENDING TO CLOSE A GAP
	SETZM DELIS1+NFILES-1		;THIS GOT A -1 FROM END OF TAB, IT WANTS 0
	MOVE B,A
	FIXGAP (B,DELIS2,NFILES,1)
	SETZM DELIS2+NFILES-1		;THIS GOT A -1 FROM END OF TAB, IT WANTS 0
	JRST DELRL


UNDEL:	MOVEI A,	;SET A UP WITH LARGEST IDX INTO DELETE LIST WITH A FILE IN IT
UNDL1:	MOVE B,DELIS0(A)
	CAME B,[-1]	;-1 OR 0 MEANS ONE ABOVE IS ONE WE SHOULD POINT AT
	CAIN B,
	JRST UNDE1	;B NOW POINTS JUST AHEAD OF LAST FILE IN LIST
	AOJA A,UNDL1	;NEXT
UNDE1:	ARGET B,1,<[JRST 4,UNDEL]>	;B IS LOOP COUNTER, A IS FILE TO UNDELETE

UNDLUP:	SOJL B,UNDONE	;ITERATE ARG TIMES ON UNDELETE STUFF
	SOJL A,UNDONE	;FILE TO REMOVE FROM DELETE LIST, STOP IF NO MORE TO UNDELETE
	PUSHJ P,INSERT	;PUT THIS FILE BACK IN FILES TABLE
	;NOW DO A FLOOKUP ON THIS FILE TO GET ITS LENGTH TO ADD TO WORD COUNT
	MOVE C,DELIS0(A);THIS IS THE FIRST FILE NAME OF FILE WE ARE UNDELETEING
	MOVEM C,UFDIN	;FOR FLOOKUP
	MOVE C,DELIS1(A);ALL THIS HAS FOR US IS EXT. 
	MOVEM C,UFDIN+1
	MOVE C,DELIS2(A);THE PPN OF THE FILE BEING UNDELTED
	MOVEM C,UFDIN+3
	FLOOKUP
	 JRST 4,.	;DOESNT GET HERE
	MOVS C,UFDIN+3	;THIS IS -SWAPPED WORD COUNT
	MOVNS C,C
	ADDM C,WORDS	;CHARGE USE FOR THIS SPACE
	SETZM DELIS0(A)	;AND ZERO THIS ENTRY IN THE LIST
	SETZM DELIS1(A)
	SETZM DELIS2(A)
	AOS TFILE ↔ AOS TFILE1	;TELL FILE COUNTERS ABOUT UNDELETEING THIS FILE
	JRST UNDLUP
UNDONE:	JRST SCYCLE	;FOR NOW...

INSERT:	SAVE A ↔ SAVE B ↔ SAVE C
	MOVEI B,	;FIND FREE SLOT IN FILES
INS1:	MOVE C,FILES(B)
	CAME C,[-1]	;FREE SLOT
	AOJA B,INS1
	MOVE C,DELIS0(A)	;GET THE FIRST FILE NAME
	HRR C,DELIS1(A)		;AND PUT IN THE UFD INDEX FOR THE FILES TABLE
	MOVEM C,FILES(B)
CPOPJ3:	POP P,C 
CPOPJ2:	POP P,B
CPOPJ1:	POP P,A
	POPJ P,
COMMENT ⊗ Put up new arrow ⊗
ARROW:	SAVE A↔SAVE B
	MOVE A,CURFIL	;CURFIL-DIPFIL IS LINE TO PUT ARROW ON
	SUB A,DIPFIL
	TRNE F,%GETTY	;SKIP IF DD
	JRST ARRIII
	IMULI A,14	;14 RASTER SCAN LINES PER TEXT LINE
	ADDI A,14*5	;ITS A LARGE FENCE?
	DPB A,[140400,,DDAMUN]	;GIVE LOLIN LOW ORDER 4 BITS OF VERT. POS
	ASH A,-4
	DPB A,[240500,,DDAMUN]	;GIVE HILIN HIGH ORDER 5 BITS
	MOVE A,DDAMUN	;UPDATE ARROW FLS PROGRAM'S HILIN AND LOLIN
	DDUPG [200000,,DDFLSA↔5↔0↔DDFMUN]	;FLUSH OLD ARROW
	DDUPG [200000,,DDARRO↔5↔0↔DDAMUN]	;PUT UP NEW ARROW(BLAST FROM THE PAST)
	MOVEM A,DDFMUN	;SO WE CAN FLS THIS NEW ARROW NEXT TIME
ARRXIT:	POP P,C↔POP P,B
	POPJ P,
ARRIII:	IMUL A,[-30]	;30 PTS PER CHR
	ADDI A,IIITOP	;Y POS OF FIRST LINE OF DIRECTORY TEXT
	UPGMVE B,IIMUNG	;GET ARROW'S LONG VECTOR WORD
	DPB A,[POINT 11,B,21]
	UPGMVM B,IIMUNG	;MUNG!
	JRST ARRXIT
COMMENT ⊗ Exit to DDT or World ⊗
UEXIT:	SKIPE DELIS0		;IF THERE IS AT LEAST ONE FILE TO DELETE TYPE MSG.
	OUTSTR [ASCIZ /
Running your delete list.../]
	PUSHJ P,XITING
	PUSHJ P,WTMPC	;WRITE A TEMPCORE FILE
	PUSHJ P,CLEAR
	EXIT
UDDT:	TRNE F,%GETTY	;ON III'S ONLY
	PGACT		;TURN OFF III PROG RUNNING DISPLAYING DIRECT
	TRNN F,%GETTY	;ON DD'S ONLY
	DDUPG [200000,,DDFLSA↔5↔0↔DDFMUN]
	MOVEM A,UDDTS
	MOVEI A,UDDTRE	;SO ↑P'ING FROM DDT WILL WORK
	MOVEM A,.JBOPC↑
	MOVE A,UDDTS
	JRST DDT↑
UDDTRE:	PUSHJ P,DPYINI	;RESEDT DISPLAY AFTER THAT BOUT WITH RAID
	JRST RIHANG
UDDTS:	0
	;STUFF A HERE WHILE SETTING UP .JBOPC FOR DDT
COMMENT ⊗ Run Delete list, and clear ⊗
XITING:
	TRNE F,%READO	;DIRECT RETURN IF IN READONLY MODE
	 POPJ P,
	SAVE A ↔ SAVE B ↔ SAVE C
	TRZN F,%DDELS	;IF WE ARE RUNNING THE DELETE LIST, GET THIS GUY OUT OF
			;DELETE LIST DISPLAY MODE
	JRST XITIP
	SETZM CURFIL	;AND SET DISPLAY TO TOP
	SETZM DIPFIL	;DIPFIS AND CURFIS ARE IRR SINCE %DDELS IS 0
XITIP:	MOVSI A,-NFILES	;USE AS PTR INTO DELETE LIST
XITI1:	MOVE B,DELIS0(A);FILE TO DELETE
	CAIN B,		;OR IS IT ZERO, DIRECT IF NO MORE TO DELETE
	JRST XIT2	;ALL DELETED
	MOVEM B,DELBLK	;FOR LOOKUP
	MOVEM B,XITSV	;INCASE WE HAVE A PROTECT FAIL, TELL LUSER ABOUT IT
	MOVE B,DELIS1(A)
	MOVEM B,DELBLK+1
	MOVE B,DELIS2(A);THIS IS THE PPN
	MOVEM B,DELBLK+3
	LOOKUP FIL,DELBLK
	 JRST XITER2	;HMM.  CANT FIND FILE WE ARE SUPPOSED TO DELETE
	SETZM DELBLK	;0 FIRST FILE NAME TO RENAME MEANS DELETE
	MOVEM B,DELBLK+3;THE LOOKUP CLOBBERED THE PPN
	RENAME FIL,DELBLK
	 PUSHJ P,XITER	;THIS IS THE SAFEST ROOM IN THE. . .
XIT3:	SETZM DELIS0(A)	;NOW ZERO THESE ENTRIES IN DELETE LIST
	SETZM DELIS1(A)
	SETZM DELIS2(A)
	AOBJN A,XITI1
XIT2:	POP P,C ↔ POP P,B ↔ POP P,A
	POPJ P,

XITER2:	;GET HERE WHEN A FILE IN THE DELETE LIST IS NOT TO BE FOUND
	HRRZ DELBLK+1	;THIS IS THE ERROR CODE
	CAIE		;IF THE ERROR IS OTHER THAN 0 GET UPSET
	 ERR 0,<I can't find a file which I'm sure is there.>
	;GUESS THAT THE FILE WENT AWAY WHILE WE WERE HACKING.  TELL THE USER
	OUTSTR [ASCIZ /
The file /]
	TTY6 6,DELBLK	;THE FIRST FILE NAME
	OUTCHR [40]
	TTY6 3,DELBLK+1	;THE EXT.
	OUTSTR [ASCIZ / [/]
	TTY6 6,DELBLK+3	;THE PPN
	OUTSTR [ASCIZ /] has been deleted by another user./]
	JRST XIT3	;RETURN PRETENTING FILE HAS BEEN DELETED BY US, CONTINUE DELETELING
	
XITER:	;GET HERE WHEN WE CAN'T DELETE A FILE
	PUSH P,A
	HRRZ A,DELBLK+1	;THE REASON THE RENAME FAILED IS HERE
	CAIE A,2	;IS PROTECT FAIL
	 ERR 0,<Oh loss!  Delete fail for non-protection reasons on >,<
		TTY6 6,XITSV
		OUTCHR ["."]
		TTY6 4,DELBLK+1;4 BECAUSE WE NEED A SPACE, AND ,,770000 IS GOING TO BE 0
		TTY6 6,DELBLK+3
		>,< Get a wizard.>
	OUTSTR [ASCIZ /
The file /]
	TTY6 6,XITSV	;TYPE THE FIRST FILE NAME OF THE FILE PROTECTED
	OUTCHR ["."]
	TTY6 3,DELBLK+1	;THIS IS THE EXT
	OUTCHR ["["]
	TTY6 6,DELBLK+3	;THE PPN
	OUTCHR ["]"]
	OUTSTR [ASCIZ / is protected from deletion against you.
Type Y to continue running delete list: /]	;OTHERWISE GO EDIT
	CLRBFI
	INCHRW A
	CAIE A,"Y"
	CAIN A,"y"
	JRST XITER1	;THE GUY WANTS TO GO ON
	MOVE P,[-PDS,,PDL-1]	;TOTALLY FLUSH RANDOM PDL
	CLRBFI
	JRST FCYCLE
XITER1:	POP P,A
	POPJ P,
XITSV:	-1		;KEEP FILE NAME ONE HERE FOR TELLING LUSER ABOUT RENAME FAIL
COMMENT ⊗ Gobble argument ⊗
ARGIN:	SETOM ARGF		;TURN ON ARG FLAG
	MOVE B,ARG		;GET ARG SO FAR
	IMULI B,=10		;TAKE THAT!
	TRZ A,600		;TURN OFF CONTROL AND META BITS (αβ OR β)
	ADDI B,-"0"(A)
	MOVEM B,ARG		;SAVE UPDATED ARG AWAY
	JRST IHANG		;THAT'S IT, NO UPDATEING OF SCREEN NEEDED
ARGINF:	MOVEI A,NFILES
	MOVEM A,ARG
	SETOM ARGF
	JRST IHANG
ARGNEG:	SETOM ARGSGN
	JRST IHANG
ARG:	0
ARGF:	0		;0 ==> NO ARG, -1 ==> SEE ARG
ARGSGN:	0		;-1 ==> SIGN BIT ONE
COMMENT ⊗ Put up a display ⊗
PUTUP:	SAVE A↔SAVE B↔SAVE C↔SAVE D
	TRNE F,%DDELS	;DIRECT IF WE SHOULD DISPLAY THE DELETE LIST
	JRST PUTDL	;WELL, DO IT
	MOVE A,CURFIL	;CHECK TO SEE IF CURFIL IS TO LARGE
	CAMLE A,TFILE1	;SKIP IF CURFIL IS REASONABLE
	SKIPN A,TFILE	;DIRECT IF 0, DONT BARF BECAUSE THERE ARE NO FILES IN THIS UFD
	SKIPA A,TFILE	;NO ERR
	JRST FALT04	;THERE ARE SOME NUMBER OF FILES, AND CURFIL IS REDICULOUS
PUTREC:	MOVEI A,1		;FILL DIRLIN WITH THIS SO DD WILL LIKE CHRS
	MOVEM A,DIRLIN
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[440700,,DIRLIN]		;GENTXT WANTS BP SET UP FOR IT
	MOVEM A,BP7
;PUT UP SIZE, PROTECTION LINE
	TRNE F,%TTY		;XTRA CRLF ON TTYS
	OUTSTR [ASCIZ /
/]↔	SGEN [ASCIZ /......PPN = /]
	TYPE6 6,LUSER		;CRANK OUT PPN FOR UPPER LINE
	TRNE F,%FAST		;DIRECT IF WE ARE IN FAST MODE, WORDS IS USELESS
	JRST PUT11
	SGEN [ASCIZ / ....... Total /]
	TYPE6 4,LOSS0	;THE DEVICE NAME
	SGEN [ASCIZ / Space in Words = /]
	MOVE A,WORDS
	TRNN F,%KMODE	;PRINT DSK WORD SIZEZ ≥ 1000 IN K'S?
	JRST .+3	;SKIP OVER KMODE STUFF
	CAIL A,=1024	;IF GREATER OR = TO 1000 PRINT AS 69 K, NOT 69000
	JRST [	IDIVI A,=1024
		SPRINT =10,A
		SGEN [ASCIZ /./]
		SPRINT =10,B
		SGEN [ASCIZ / K /]
		JRST PUT11]
	SPRINT =10,A	;OTHERWISE JUST PRINT AS WORDS
PUT11:	SGEN [ASCIZ / ....../]
	SPRINT 8,[-36]	;CRLF
	SKIPN ANYWHO		;NON 0 ANYWHO MEANS THERE IS AT LEAST ONE FULL FILE
;	TRNE F,%FAST		;USE A DIFFERENT HEADER FOR FAST MODE
HEDLI2:	SGENA [ASCIZ /Filename Ext     P  PN
/]
HEDLIN:	SGEN [ASCIZ /Filename Ext     P  PN     Size    Date     Time  Pro  Dump Date    Last Referenced
/]↔	SKIPE DIPFIL			;SKIP IF STARS BELONG AT TOP, DIRECT IF -'S
	SKIPA A,STRIPE			;LOAD A WITH POINTER TO --'S FOR TOP LINE
	MOVE A,STARS			;OR LOAD WITH PT. TO *'S
	TRNE F,%TTY			;DIRECT IF ON A TTY
	JRST [	OUTSTR [ASCIZ /
/]↔		MOVSI A,400000	;SO AOBJN WILL NOT EXPIRE
		JRST PUTL1]	;GEN. TEXT.
	SGEN @A				;OUTPUT IT ON BP7
	SKIPE DELIS0			;IF THERE IS A FILE ASKING TO BE DELETED
	SGEN [ASCIZ / W/]		;INCLUDE THIS
	TRNE F,%READO			;IF WE ARE IN READONLY MODE SAY SOMETHING
	SGEN [ASCIZ ∧ /R∧]
	SPRINT 8,[-36]			;FOLLOWED BY CRLF
	MOVE A,DIPFIL			;USE A AS IDX INTO FILES, AND FOR GENTXT
	HRLI A,-NLINES			;FOR AOBJN
PUTL1:	MOVE B,FILES(A)			;FILES PTR. ON FILE CONSIDERING GENTXT'ING
	CAMN B,[-1]			;-1 INDICATES LAST FILES ENTRY PAST
	JRST PUT1			;WE RAN OUT OF FILES TO LIST, **'S PLS
	PUSHJ P,GENTXT			;CHEW ENGLISH OUT TO BP7
	AOBJN A,PUTL1
	SKIPE ZERO		;DEBUG CHECK TO SEE IF DIRLIN WAS MORE THAN FILLED
	ERR 0,<GENTXT overshot buffer, somethin's wrong.  Remember what you were doing.>
	MOVE B,FILES(A)			;THIS IS NEXT FILE OFF THE BOTTOM OF SCREEN
	CAME B,[-1]			;IF EXISTS SHOW --'S TO INDICATE MORE, ELSE
	SKIPA C,RSTRIPE			;THERE IS ANOTHER FILE OFF THE BOT OF SCREEN
PUT1:	MOVE C,RSTARS			;NO FILES OUT THERE
	TRNE F,%TTY			;DIRECT IF ON TTY
	JRST TVRLSG
	SGEN @C
	PUSHJ P,MSKO			;PUMP OUT THESE **'S OR --'S AND FILE MASK
PUTDP:	SGEN @C
	SUB A,[1,,1]	;MAKE AOBJN POINTER THAT MUCH MORE FRIENDLY
	SPRINT 8,[-36]	;AT LEAST ON CRLF, WITHOUT THE SPACES
	JRST .+2	;WE MAY NOT WANT ANY SPACES AT ALL, ASK AOBJN PTR. FIRST
	SGEN [ASCIZ /                                                                                    
/]		;∞ SPACES, CRLF.  FLUSH TEXT ON CURRENT LINE, MOVE TO NEXT
	TRNN F,%GETTY	;ON III PRINT ONLY 1
	AOBJN A,.-2	;PRINT AT LEAST ONE CRLF
	TRNE F,%GETTY
	JRST PUTIII	;III DON'T THINK DD CAN HACK IT PHYLS.
	DDUPG [200000,,DDHEAD↔DIRLEN+3↔0↔DDMUNG]
PUTXIT:	RECALL D↔RECALL C↔RECALL B↔RECALL A
	POPJ P,
PUTIII:	AOS A,BP7	;THIS GOT THE LOCATION WE WERE WRITING TEXT INTO LAST
	SUBI A,IIHEAD	;
	HRRZM A,IIIBLK+1	;THIS IS WHERE LENGTH OF PRG KEPT
	DPYOUT IIIBLK
	PGACT (<SETZ>)
	PGSEL
	JRST PUTXIT
IIIBLK:	IIHEAD	;POINTS AT PROG
	0	;LENGTH GETS SET UP
STARS:	[ASCIZ /************************/]
STRIPE:	[ASCIZ /------------------------/]
RSTARS:	[ASCIZ /******* /]
RSTRIP:	[ASCIZ /------- /]

TVRLSG:	OUTSTR DIRLIN		;PUMP OUT ALL THAT %"&!
	EXIT

MSKO:	PUSH P,A ↔ PUSH P,B
	MOVEI A,	;A IS IDX TO MMASK
	SGEN [ASCIZ /File Mask = /]
	MOVEM A,MSKFOO#
MSKO0:	CAIN A,6
	JRST MSKO1
	SKIPGE MMASK(A)
	AOJA A,MSKO0
	MOVE A,MSKFOO
	MOVE B,MMASK(A)
	CAIGE B,	;- MEANS WE'VE GOT AN ANYBODY'S
	SKIPA B,["∀"]
	ADDI B,40
	IDPB B,BP7
	AOJA A,MSKO0-1
MSKO1:	SKIPGE MMASK-1(A)	;MORE CHRS?
	SGEN [ASCIZ /*/]
	SGEN [ASCIZ /  /]

	MOVEM A,MSKFOO
MSKO5:	CAIN A,9
	JRST MSKO6
	SKIPGE MMASK(A)
	AOJA A,MSKO5
	MOVE A,MSKFOO
	MOVE B,MMASK(A)
	CAIGE B,
	SKIPA B,["∀"]
	ADDI B,40
	IDPB B,BP7
	AOJA A,MSKO5-1
MSKO6:	SKIPGE MMASK-1(A)
	SGEN [ASCIZ /*/]
	SGEN [ASCIZ / /]
	POP P,B ↔ POP P,A ↔ POPJ P,


PUTDL:	;GET HERE TO DISPLAY DELETE LIST
	MOVEI A,1	;BLT DIRLIN TO 1'S FOR DD
	MOVEM A,DIRLIN
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[440700,,DIRLIN]
	MOVEM A,BP7
;PUT UP HEADER LINE FOR DELETE LIST MODE
	SGEN [ASCIZ /......PPN = /]
	TYPE6 6,LUSER	;CRANK OUT THE 6 SIXBIT CHRS IN LUSER TO BP7 (ASCII)
	SGEN  [ASCIZ / ....... Total /]
	TYPE6 4,LOSS0	;THE DEVICE NAME
	TRNE F,%FAST
	JRST PUTDL1	;IN FAST MODE WE DONT KNOW ABOUT WORDS
	SGEN [ASCIZ / Space in Words = /]
	MOVE A,WORDS
	TRNN F,%KMODE	;PRINT DSK WORD SIZEZ ≥ 1000 IN K'S?
	JRST .+3	;SKIP OVER KMODE STUFF
	CAIL A,=1024	;IF GREATER OR = TO 1000 PRINT AS 69 K, NOT 69000
	JRST [	IDIVI A,=1024
		SPRINT =10,A
		SGEN [ASCIZ /./]
		SPRINT =10,B
		SGEN [ASCIZ / K /]
		JRST PUTDL1]
	SPRINT =10,A	;OTHERWISE JUST PRINT AS WORDS
PUTDL1:	SGEN [ASCIZ / ......
Filename   Ext      P PN
/]↔	SKIPE DIPFIL	;IF WE ARE AT TOP (0) USE **'S
	SKIPA A,STRIPE	;USE 'EM ----'S
	MOVE A,STARS
	SGEN @A
	SPRINT 8,[-36]	;CRLF
	MOVE A,DIPFIL	;THIS IS WHERE WE SHOULD START DISPLAYING FROM IN THE LIST
	HRLI A,-NLINES	;AOBJN ON PRODUCE ING TEXT
PUTD1:	MOVE B,DELIS0(A);SO GET WINNING FIRST FILE NAME OF THIS DELETE LIST FROB
	JUMPE B,PUTD2	;WE'RE SURE THRU, NO MORE CRUFTIES BEFORE RAN OUT OF SCREEN
	TYPE6 6,B	;PRINT THE FILE NAME FOR THE GUY
	SGEN [ASCIZ /     /]	;A LITTLE SPACE BETWEEN FILE NAMES
	TYPE6 3,DELIS1(A)	;THIS IS THE EXT, ONLY 3 CHRS
	SGEN [ASCIZ /    /]
	TYPE6 6,DELIS2(A)	;WHAT COULD BE EASIER, THE PPN
	SPRINT 8,[-36]	;CRLF
	AOBJN A,PUTD1
	MOVE B,DELIS0(A)	;SEE IF THERE IS ANOTHER FILE OUT THERE OFF THE
			;BOT OF SCREEN SIZE
	CAIE B,
	SKIPA C,RSTRIP	;THERE'S ANOTHER GUY OUT THERE, USE ---'S
PUTD2:	MOVE C,RSTARS
	SGEN @C
	SGEN [ASCIZ /Delete list Mode /]
	JRST PUTDP	;NOW PUT THIS TRASH UP
COMMENT ⊗ Initialization ⊗
GETSET:	INIT UFDC,10
LOSS0:	SIXBIT /DSK/
	UFDNUL
	 JRST FATL02		;CAN'T INIT?
	INIT FILC,410		;400 BIT FOR LONG LOOKUPS
LOSS1:	SIXBIT /DSK/
	FILNUL
	 JRST FATL02
	INIT FIL,16
LOSS2:	SIXBIT /DSK/
	0
	 JRST FATL02
	INIT MFDC,10
LOSS3:	SIXBIT /DSK/
	MFDNUL
	 JRST FATL02

comment ⊗
DPYINI:	GETLIN A		;TELL LUSER HE IS LUSING IFF NOT DISPLAY
	TLNN A,20000!400000	;SKIP IF DD OR III
	JRST FATL07		;NOT DISPLAY
	TLNE A,(<SETZ>)		;direct IF III, skip IF DD
	TROA F,%GETTY		;ONE MEANS III
	TRZ F,%GETTY		;0 IS DD
⊗
dpyini:	TRNE F,%TTY	;SKIP IF ON DISPLAY
	POPJ P,
	PPSEL 2
	DPYSIZ 4*1000+1
	TRNN F,%GETTY	;DIRECT ON DD
	DPYPOS -1000+14*=9
	TRNE F,%GETTY
	DPYPOS -1000+=24*4
	PPACT 100000
	TRNN F,%GETTY	;III WANTS LITTLE MORE HELP GETTING STARTED
	POPJ P,
	PGSEL		;MAKES UPG MOVES WORK
	PGACT (<SETZ>)	;DISPLAYS POG 0
	SETZM DDHEAD	;SYSTEM III STUFF GETS CONFUSED BY DD PROGRAM
	SETZM DDMUNG
	POPJ P,
COMMENT ⊗ Read UFD and produce FILES table ⊗
REAUFD:	SETOM FILES		;FILL FILES WITH -1'S TO INDICATE UNFILLED CELLS
	MOVE A,[FILES,,FILES+1]
	BLT A,FILES+NFILES-1
	SETOM LUKDAT		;FILL LOOKDAT WITH -1 SO UUO CAN FAIL IF FILE IS NX
	MOVE A,[LUKDAT,,LUKDAT+1]
	BLT A,LUKDAT+NFILES*7-1	
	MOVE A,[['  1  1' ↔ 'UFD   ' ↔ 0 ↔ '  1  1'],,UFDIN]
	BLT A,UFDIN+3
	LOOKUP MFDC,UFDIN	;OPEN 1,1
	 ERR 0,<I can't find the MFD.>
	MOVSI I,-NFILES
	;FOR SINGULAR PPNS DONT READ THE ENTIRE MFD
	MOVE A,[440600,,LUSER]	;GO THRU LUSER LOOKING FOR ?'S
REPEAT 6,<
	ILDB B,A	;GET A CHARACTER OF THE PPN TYPED BY LUSER
	CAIN B,'?'	;BREAK OUT OF THIS REPEAT AND DO THE NORMAL THING
	JRST REA10	;IF THERE ARE ANY ?'S
	>
	MOVE II,LUSER	;WE GET HERE IF LUSER HAS NO ?S IN PPN, FAKE IT
	USETI MFDC,377777	;WAY OFF THE END OF THE MFD...
	JRST REASNG
REA10:	GET MFDC,II	;THIS HERE FIRST WORD SHOULD BE A UFD NAME
	JRST REASIZ	;WIN! NO MORE UFD'S
	GET MFDC,B	;BUT MAKE SURE THE EXT IS REALLY "UFD"
	 JRST 4,.
	TRZ B,-1	;TURN OFF THIS GARBAGE.  WE CONSERNED WITH EXT NAME
	CAME B,['UFD   ']	;DIRECT IF THIS ISNT EVEN A UFD
	 JRST [	EXCH A,FLCTXX# ↔ MOVEI A,=14 ↔ EXCH A,FLCTXX
		GET MFDC, ↔ JRST 4,.	;NOT A UFD, FLUSH RECORD
		SOSLE FLCTXX ↔ JRST $.-3
		JRST REA10]
	EXCH A,FLCTXX ↔ MOVEI A,=13 ↔ EXCH A,FLCTXX
	GET MFDC, ↔ JRST 4,.
	SOSLE FLCTXX ↔ JRST .-3	;TAKE THE 3rd-15th WORDS OF RECORD AWAY.  THE
	;16th WILL BE COLLECTED BY REASNG, DOUBLING AS A TEST FOR NON SINGULAR PPNs
	;IN WHICH CASE, DON'T TYPE 'Reading UFD' MESSAGE.

	PUSHJ P,REAMAT		;SKIP RETURN IF WE HAVE A MATCH TO 'LUSER'
	JRST [GET MFDC,↔JRST 4,. ↔ JRST REA10]
		;WILL HAVE TO COLLECT 16th WORD FOR REASNG, AND TRY ANOTHER UFD REC.

		;FALL THROUGH TO REASNG, WE HAVE A MATCH


REASNG:	SETZM WORDS
	MOVEM II,UFDB	;FOR FIRST FILE NAME, OPEING THE UFD
	MOVSI A,'UFD'
	MOVEM A,UFDB+1	;FOR SECOND FILE NAME
	MOVE A,[21,,21]	;PPN OF [1,1]
	MOVEM A,UFDB+3
	LOOKUP UFDC,UFDB	;TRY TO GET THIS USERS UFD OPEN
	 JRST REA10		;IGNORE THIS, GO ON TO BIGGER AND BETTER PPNS
	GET MFDC,		;COLLECT THE 16TH WORD, AND DECIDE IF WE SHOULD
	CAIA			;PRINT 'Reading UFD' MESS
	JRST READ1		;OR NOT.
	OUTSTR [ASCIZ /
Reading UFD for user /]
	PUSHJ P,PRWHO	;PRINT LUSER ON TTY
	OUTSTR [ASCIZ / - /]
;II HAS THE PPN WE DEALING WITH, GOT IT FROM MFD.  I IS THE AOBJN AC
READ1:
	MOVEI C,	;FIND FREE SPACE IN LUKDAT
read1b:	MOVE D,LUKDAT(C)
	CAME D,[-1]
	CAIN D,
	JRST READ1A	;FREE
	ADDI C,7
	JRST READ1B
READ1A:
	movem c,lukpt
	GET UFDC,B	;GET WORD INTO B, WHICH SHOULD BE THE FIRST FILE NAME
	 JRST REA10	;NON SKIP MEANS EOF HAS BEEN READED ON THIS UFD, NO MORE
		; FILES IN THIS UFD, GO ONE READING MFD FOR ANOTHER UF
	movem b,ufdibf
	GET UFDC,C		;GET THE EXT,
	 JRST 4,.	;SHOULD NOT EOF IN MIDDLE OF UFD ENTRY
	movem c,ufdibf+1
	get ufdc,ufdibf+2;word (2)
	 jrst 4,.
	get ufdc,ufdibf+3	;throw away
	 jrst 4,.
	get ufdc,ufdibf+3 ↔ jrst 4,.
	movns ufdibf+3
	movss ufdibf+3
	get ufdc,ufdibf+4 ↔ jrst 4,.	;throw away 5
	get ufdc,ufdibf+4 ↔ jrst 4,.
	get ufdc,ufdibf+5 ↔ jrst 4,.
	EXCH A,FLCTXX ↔ MOVEI A,=8 ↔ EXCH A,FLCTXX
	GET UFDC, ↔ JRST 4,.
	SOSLE FLCTXX ↔ JRST .-3
	JUMPE B,READ1	;ZERO FILE NAME MEANS THIS ENTRY IN UFD NOT USED
	CAMN B,[-1]	;-1 FILE NAME IS OK WITH SYSTEM, BUT NOT WITH DIRED
	JRST READ1	;IGNORE IT THEN
	MOVEM B,UFD(I)	;PUT THE FIRST FILE NAME IN THE UFD TABLE
	MOVEM C,UFD2(I)	;PUT THE EXT,,CREATION DATE
	MOVEM II,LLUSER(I)	;AND KEEP PPNS PARR
	PUSHJ P,CMASK	;CHECK MASK, SKIP RETURN IF THIS FILE SHOULD BE ALLOWED IN UFD
	 JRST READ1	;THIS FILE IS MASKED OUT, GET THE NEXT UFD ENTRY
	HRR B,I		;PUT THE UFD ENTRY NUMBER IN RIGHT HALF
	MOVEM B,FILES(I);STUFF IN FILES, PERHAPS TO BE SORTED LATER
	camn ii,['  1  1']	;MFD doesnt have new ufd format
	jrst read1l
	push p,c ↔ push p,b
	movsi c,ufdibf
	hrr c,lukpt
	addi c,lukdat
	move b,lukpt
	blt c,lukdat+5(b)
	movem ii,lukdat+6(b)
	pop p,b ↔ pop p,c
READ1L:	AOBJN I,READ1	
	OUTSTR [ASCIZ /
I don't have enough room for all those files.
I stopped reading at /]
	TTY6 6,UFD-1(I)	;-1 BECAUSE DID AOBJN
	OUTCHR ["."]
	TTY6 3,UFD2-1(I)
	OUTSTR [ASCIZ / in [/]
	TTY6 6,II	;THE PPN SHOULD STILL BE THERE
	OUTSTR [ASCIZ /] - /]
	;FALL THRU TO REASIZ AS IF MFD'S END HAD BEEN REACHED
REASIZ:	;GET HERE WHEN DONE READING UFD.  CAUSE ALL THE FILES TO BE LOOKED UP, AND 
	;GET WORD COUNT ON ALL FILES
	TRNE F,%FAST	;DIRECT IF IN FAST MODE
	JRST [	MOVE A,I	;RETURN EXPECTS TO FIND OLD AOBJN AC IN A
		POPJ P,		;DONT DO ANY LOOKUP STUFF
		]
;	OUTSTR [ASCIZ /Reading Lookup Data - /]
	SETZM WORDS	;COUNT OF WORDS IN FILE
	SETZM FULWHO	;WE ARE LOOKING UP ALL, MIGHT AS WELL INDICATE THEY ARE ALL
	MOVE A,[FULWHO,,FULWHO+1]	;LOOKED UP..
	BLT A,FULWHO+NFILES-1
	SETOM ANYWHO	;INDICATE AT LEAST ON FILE HAS BEEN LOOKED UP [SOON..]
	MOVSI A,-NFILES	;AOBJN AC
	MOVEI D,	;LOW ORDER BIT OF D IS LOOKED AT, CLEARED WHEN TESTED.
	;CONSIDER ALL THE FILES IN ORDER FOUND IN FILES (AOBJN AC IS FILES IDX)
REA1:	MOVE B,FILES(A)	;SETS B UP WITH INDX INTO UFD TABLES
	CAME B,[-1]	;-1 IN FILES INDICATES WE HAVE HIT THE END
       JRST CPOPJ+1
REALEA:	CLOSE UFDC,	;CLOSE OUT IO
	CLOSE MFDC,
	CLOSE FILC,
CPOPJ:	POPJ P,
	MOVE C,UFD(B)	;GET THE FIRST FILE NAME
	MOVEM C,UFDIN	;PUTS IT IN LOOKUP BLOCK
	MOVE C,UFD2(B)	;GET THE EXT
	MOVEM C,UFDIN+1	;FOR LOOKUP
	MOVE C,LLUSER(B);GET THE PPN
	MOVEM C,UFDIN+3
	FLOOKUP		;DO THE RIGHT THING
	 TROA D,1	;SO WE WILL JRST (NOT AOBJN) WHEN WE LOOP NEXT TIME
	JRST .+2	;SKIPA
	 REMOVE 1,A	;CANT LOOKUP FILE, PROTECT ERROR.  REMOVE IT FROM FILES TAB
	MOVS E,UFDIN+3	;GET NEG SWAPED WORD COUNT (SWAP IT)
	MOVN E,E
	ADDM E,WORDS	;BUMP WORD COUNT UP BY THAT
	HRLM E,FILES(A)	;HIDE THE WORD COUNT FOR FILES IN LEFT HALF OF FILES WORDS
	MOVE E,UFDIN+2		;THIS HAS LOW 12. OF DATE, AND TIME
	DPB E,[271400,,E]	;PUT THE DATE ABOVE THE TIME
	LSH E,-=12	;MAKE ROOM FOR 3 BITS, AND FLUSH 12 MOVED BITS OF DATE OFF END
	LDB C,[170300,,UFDIN+1]	;THIS IS WHERE "DATE 75" HIGH ORDER 3 BITS OF DATE ARE
	DPB C,[270300,,E]	;STICK THE HIGH 3 BITS OF DATE WHERE THEY BELONG
	MOVEM E,DATES(B)
	TRZE D,1	;THIS GETS SET IF WE SHOULD NOT AOS A
	JRST REA1	;THE FILES TABLE HAS BEEN SHUFFLED SO THAT WE ARE NOW
		;POINTING AT THE NEXT ENTRY WITHOUT HAVING TO AOS IDX
	AOBJN A,REA1	;AGAIN.
	MOVE B,FILES(A)
	CAME B,[-1]	;THIS BETTER -1 OFF THE END OF FILES TABLE
	ERR 0,<Inconsistancy in FILES, there seem to be more files than room in table.>
	JRST REALEA	;OK, LEAVE AFTER CLOSING ALL THE CHANS

CMASK:	PUSH P,A ↔ PUSH P,B ↔ PUSH P,C ↔ PUSH P,D
	;SKIP IF THE FILE IN B & C IS LIKED BY CURRENT MASK
	MOVE A,[440600,,B]	;CHECK THESE CHARACTERS AGAINST THE MASK
	FOR ZZ←0,8,1 <
	IBP A
	SKIPGE MMASK+ZZ		;NEG MEANS MATCH ANY CHARACTER
       JRST .+4
	LDB D,A	;GET A CHARACTER
	CAME D,MMASK+ZZ	;MUST MATCH EX.
	JRST CMOUT	;THIS FILE LOSES
	>
	POP P,D ↔ POP P,C ↔ POP P,B ↔ POP P,A
	AOS (P)
	POPJ P,
CMOUT:	POP P,D ↔ POP P,C ↔ POP P,B ↔ POP P,A
	POPJ P,

REAMAT:	;SKIP RETURN IF PPN IN II FALLS WITHIN MASK SPECFIED BY LUSER
	PUSH P,A ↔ PUSH P,B ↔ PUSH P,C ↔ PUSH P,D
	MOVE A,[440600,,II]	;BP INTO THE PPN BEING CHECKED
	MOVE B,[440600,,LUSER]
REPEAT 6,<
	ILDB C,B
	ILDB D,A		;C HAS MASK CHR, D HAS TEST PPN
	CAIN C,(D)		;DIRECT IF THESE GUYS LIKE EACH OTHER
       JRST .+3
	CAIE C,'?'		;SKIP IF WE ARE SUPPOSED TO TAKE THIS ANYWAY (?)
	JRST REAMTE		;A REAL HONEST LUSER!
	>
       AOS -4(P)		;SKIP RETURN
REAMTE:	POP P,D ↔ POP P,C ↔ POP P,B ↔ POP P,A
	POPJ P,

ufdibf:	block 6
lukpt:	0
COMMENT ⊗ Line Editing ⊗
;PUT DIRECTORY LINE IN LINE EDITOR.  AFTER USER EDIT, READ IT INTO RENAME BLOCK
;AND RENAME THE FILE(ACCORDING TO TTY EDIT).
LINE:	TRNN F,%DEBUG	;SKIP IF WE ARE GOING TO LET THIS HAPPEN
	JRST RIHANG
	MOVEI A,1	;SET DIRLIN TO 1
	MOVEM A,DIRLIN
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[440700,,DIRLIN]	;BYTE POINTER FOR GENTXT
	MOVEM A,BP7
	MOVE A,CURFIL
	PUSHJ P,GENTXT
	PTLOAD [0 ↔ DIRLIN]
;IN THE MEAN TIME, PREPARE BLOCKS FOR RENAME
	MOVE B,FILES(A)	;THIS GETS US A UFD INDEX
	MOVE C,UFD(B)	;THIS GETS US FIRST FILE NAME OF FILE HACKING
	MOVEM C,UFDIN	;WE ARE GOING TO DO A FLOOKUP ON THIS FILE TO GET ALL THE
	MOVE C,UFD2(B)	; OLD DATA FOUND IN A LOOKUP ON THIS FILE
	MOVEM C,UFDIN+1	;SECOND FILE NAME
	MOVE C,LLUSER(B);PPN
	MOVEM C,UFDIN+3
	LOOKUP FILC,UFDIN;OPEN THIS FILE FOR RENAME
	 JRST 4,.	;HMM, WHERE DID IT GO?
	MOVE B,[UFDIN,,RENBLK]	;NOW SET UP RENAME BLOCK WITH OLD DATA
	BLT B,RENBLK+5			;IN CASE WE DON'T MODIFY ALL OF IT
	ACTCHR A,	;WAIT TILL HE IS THRU WITH THIS LINE
;PROCESS THE EDITED LINE COMMING IN ON THE TTY
	CAIN A,175	;DID HE TERMINATE WITH AN ALT?
	POPJ P,		;GIVE UP

NRSYCL←←0

DEFINE RSYLAB ! (SYLAB,BREAK,BRKSET)
	<
;<BRKSET 0 ==> BREAK ON SPACE, CR
NRSYCL←←NRSYCL+1
JRST [	MOVE SYLAB,[440600,,SYLAB]	;THIS WILL BE THE BP FOR SYLAB WE READING
	MOVEM SYLAB,SYBP6Z#		;WE WILL BE OPERATING OUT OF STOCKHOLM
	MOVEI SYLAB,
CONC(RSYC,\NRSYCL): INCHRS BREAK,	;GET A CHARACTER FROM THE SYLAB
	 SKIPA BREAK,[15]		;THE ACTCHR UUO STOLE THE CR FROM E-O-L
	FOR ZZZ E {BRKSET}		;JRST .+1 IF THIS IS ANY OF THE BREAK CHAR
	<CAIN BREAK,"ZZZ"		;DIRECT IF THIS IS AN OFFICAL BREAK CHAR
	 JRST .+1			;RETURN FROM CONSTANTINOPLE
	>;FOR BRKSET
	CAIL BREAK,"`"			;DIRECT IF LOWER CASE ASCII
	SUBI BREAK,100			;MAKE UPPER CASE OUT OF IT
	SUBI BREAK,40			;AND THEN MAKE SIXBIT OUT OF IT
	IDPB BREAK,SYBP6Z		;GET OUTA HERE
	JRST CONC(RSYC,\NRSYCL)		;NOTHER GO AT IT (NEXT CHR)
	];JRST
	>;DEFINE RSYLAB

	RSYLAB (A,B,. )			;GET THE TTYs IDEA OF A FIRST FILE NAME
	PUSHJ P,EATBRK
	MOVEM A,RENBLK			;PUT IT IN THE RENAME BLOCK
	RSYLAB (A,B, [)	;GIVE A EXT
	PUSHJ P,EATBRK
	HLLZM A,RENBLK+1		;PUT THE EXT IN RENAME BLOCK
	RSYLAB (A,B,<,] >)		;GET PPN,BE PREPARED FOR [105,SGK] STYLE TOO
	CAIN B,","		;DIRECT IF [105,SGK] STYLE PPN, AND WE HAVE LEFT .5
	JRST [	HLLM A,RENBLK+3;THE LEFT HALF OF THE PPN
		MOVEI A,	;FIND OUT WHAT TO DO WITH RIGHT HALF INCASE USER...
		DSKPPN A,	;DOESNT SAY
		HRRM A,RENBLK+3	;IF THERE IS A <,SGK> USE IT INSTEAD, LATER
	     ]
	CAIN B,"]"		;DIRECT IF END OF [105] STYLE PPN, PROBABLY
	JRST [	MOVEM A,RENBLK+3;SAVE PPN.
		;IF [105SGK] STYLE, LEAVE IT BE. IF [105] STYLE, FILL RIGHT HALF
		;WITH SAME OF ORIGINAL FILE
		TRNE A,-1		;SKIP IF [105] STYLE
		JRST LINE1		 ;PPN ALL DONE.  MAY I HAVE THE NEXT SLIDE
		MOVE A,CURFIL		;GET THE PPN FOR THE CURRENT FILE
		MOVE A,FILES(A)		;GET THE UFD POINTER FOR THIS FILE
		MOVE A,LLUSER(A)	;AND FINALLY, GET THE PPN
		HRRM A,RENBLK+3		;USE SAME RIGHT HALF OF PPN AS ORG FILE
		JRST LINE1
	     ];JRST
LINE1:	;CONTINUE READING LINE, IGNORE SIZE, GET DATE
	RSYLAB (A,B, )		;EAT THE FILE SIZE
	PUSHJ P,EATBRK		;SHOULD BE RIGHT UP AGAINST 26-Nov-74
	CLRBFI		;THATS IT FOR NOW
LINE2:	;DONE READING LINE, DO RENAME AND MODIFY INTERNAL DATA ON FILE
	RENAME FILC,RENBLK	;DO IT
	 ERR 0,<Rename Fails>
	LOOKUP FILC,RENBLK	;NOW RE LOOK IT UP TO GET NEW DATA
	FLOOKUP			;FIND OLD FILE'S DATA, LEAVE POINTER IN FLKDAT

EATBRK:	PUSH P,A
ETBRK1:	SNEAKS A,
	JRST CPOPJ1			;NO CHARACTERS, FLUSH ANYWAY
	CAIE A,"["			;EAT [ AND ]s TOO
	CAIN A,"]"
	JRST EATIT
	CAIL A,"1"			;SKIP IF TO BE EATEN
	JRST CPOPJ1			;STOP EATING CHARCTERS WITH THIS ONE, RETURN
EATIT:	INCHRW A			;WASTE IT
	JRST ETBRK1			; AND CONTINUE LOOKING FOR
COMMENT ⊗ Produce english for line editor ⊗
LINTXT:	PUSH P,A ↔ PUSH P,B ↔ PUSH P,C
	...
COMMENT ⊗ Produce english of of file pointed to by A in DIRLIN ⊗
GENTXT:	SAVE A↔SAVE B↔SAVE C↔SAVE D
	MOVE A,FILES(A)		;GET UFD INDEX OF THIS FILE FROM FILES
	SKIPE FULWHO(A)		;SKIP IF THIS FILE WANTS TO BE DISPLAYED IN FULL
	TLZA A,1		;USE 1,, TO INDICATE TO DO LOOKUP
	TLO A,1
	MOVE B,UFD(A)		;GET FIRST FILE NAME OF THIS FILE FROM UFD TABLE
	MOVE C,UFD2(A)		;AND THE 2.ND
	MOVE D,LLUSER(A)	;THE PPN
	MOVEM B,UFDIN	;FOR LOOKUP
	MOVEM C,UFDIN+1
	MOVEM D,UFDIN+3
	TLNN A,1		;IN FAST MODE DONT DO LOOKUPS [FOR THIS FILE] [HIDE BIT HERE]
       JRST .+3
	FLOOKUP FILC,UFDIN	;GET LONG FORM LOOKUP DATA IN UFDIN (USER UUO)
	 JRST 4,.
	TYPE6 6,B		;TYPE FIRST FILE NAME
	SGEN [ASCIZ /   /]
	TYPE6 3,C		;TYPE FILE NAME 2
	SGEN [ASCIZ /    /]
	TYPE6 6,D		;TYPE PPN
	SGEN [ASCIZ /   /]	;ONE BIG FAT JUICY TAB
	TLNN A,1		;NO OTHER INFORMATION AVAILABLE IF IN FAST MODE
	JRST GENTEX
	MOVS A,UFDIN+3	;GET -SWAP WD. CNT   (I THOUGHT THERE WAS A J IN JUICE)
	MOVNS A		;NEGATE IT
	SETZM CCT	;ZERO CHR. COUNT FOR TABING OUT
	PUSHJ P,SIZSPC	;PRINT A NUMBER OF SPACES TO RIGHT ADJUST SIZE.
	TRNN F,%KMODE	;SKIP IF WE ARE IN KMODE (69000 PRINTS AS 69 K)
	JRST .+3
	CAIL A,=1024	;GREATER THAN K? 
	JRST [	IDIVI A,=1024
		SPRINT =10,A
		SGEN [ASCIZ / K/]
		AOS CCT
		JRST GENT6]
	SPRINT =10,A	;CRANK OUT CHRS TO BP7
GENT6:	SGEN [ASCIZ /  /]
	HRRZ A,UFDIN+2	;7777 CONTAINS DATE, HIGH 3 IN HIGH 3 OF RT OF +1
	LDB C,[170300,,UFDIN+1]	;GET THE HIDDEN HIGH 3 BITS
	DPB C,[140600,,A]	;PUT THEM WITH REST OF DATE BITS
	IDIVI A,=31
	ADDI B,1	;REMAINDER IS DAY-1
	CAIGE B,=10	;IF LESS THAN 10 TYPE A SPACE TO FORCE IT TO TAKE 2 POS.
	SGEN [ASCIZ / /];LIKE I SAID, NUMBER ONE DIGIT, TAKE 2 POSITIONS
	SPRINT =10,B	;CRANK DAY OUT
	IDIVI A,=12
	XCT MONTHS(B)	;UUO WILL PRINT NAME OF MONTH
	ADDI A,=64	;OR 1964 FOR FULL YEAR NUMBER,,,,
	SPRINT =10,A	;GUESS
	SGEN [ASCIZ/  /];BLOOD IS THICKER THAN PRUNE JUICE
	LDB A,[141300,,UFDIN+2]	;TIME WRITTEN
	IDIVI A,=60	;CHOMP IT UP INTO HOURS AND MINS.
	MOVE C,B	;HOLD THESE MINS. FOR A MIN..
	IDIVI A,=10	;GIVE ME TWO DIGITS OF LOSSAGE
	SPRINT =10,A	;THIS HAS ONE DIGIT OF HOUR
	SPRINT =10,B	;AND HERE IS THE OTHER
	IDIVI C,=10	;NOW BREAK MINS INTO TWO DIGITS TO INSIST ON LEADING 0
	SPRINT =10,C	;C HAS HIGH ORDER MIN
	SPRINT =10,D
COMMENT ⊗ REMOVED BEACUSE OF %DEVUO HACK (USE SPRINT UUO INSTEAD
	ADDI A,"0"↔ADDI B,"0"	
	IDPB A,BP7↔IDPB B,BP7
	IDIVI C,=10	;TAKE MINS APART INTO TWO DIGITS
	ADDI C,"0"↔ADDI D,"0"
	IDPB C,BP7↔IDPB D,BP7
	⊗
	SGEN [ASCIZ/  /];TAB
	MOVE A,[440300,,UFDIN+2]	;BP FOR PRO
REPEAT 3,{ILDB B,A	;GET NUMBER
	ADDI B,60
	TRNE F,%DEVUO	;DIRECT IF THE DEVICE FLAG IS ON
	JSR B,.TAKE	;IN WHICH CASE USE THIS TO OUTPUT TO DEVICE (SKIP RETURN)
	IDPB B,BP7}
	MOVE A,UFDIN+5	;GET THE DUMP INFORMATION WORD
	TLNN A,20000	;SKIP IF THIS DUMP INFO IS INVALID
	JRST GENT7	;NO, ITS OK NOW PRINT IT
	SGEN [ASCIZ /             /] ;PRINT SPACES INSTEAD OF DUMP INFO
	JRST GENT9
GENT7:	SGEN [ASCIZ / /]
	MOVEI A,77777	;THESE ARE THE BITS FOR THE DATE, IN SYS FORMAT
	AND A,UFDIN+5	;GET THEM
	CAIN A,		;IF THIS IS ZERO, NO DATE
	JRST	[SGEN [ASCIZ /            /]	;FILE NOT DUMPED
		JRST GENT9]
	IDIVI A,=31
	ADDI B,1
	CAIGE B,=10	;WE GOING TO GET ONE OR TWO DIGITS OUT OF THIS?
	SGEN [ASCIZ / /]	;ONE
	SPRINT =10,B	;LETS HERE IT, THIS IS THE DAY
	IDIVI A,=12	;NOW SQUEEZE THE MONTH OUT OF THIS
	XCT MONTHS(B)
	ADDI A,=64	;GIVES US RANDOM YEAR, ADD 1964 FOR 4 DIGIT YEAR NUMBER
	SPRINT =10,A
	SKIPL UFDIN+5	;SIGN BIT IS PERM/TEMP BIT
	SGENA [ASCIZ  /P /]
	SGEN [ASCIZ /T /]	;1 ==> TEMP
	LDB A,[400300,,UFDIN+5]	;GET THE NUMBER OR PERM DUMPS
	SPRINT =10,A
GENT9:	SGEN [ASCIZ /  /]
	MOVEI A,77777	;THESE ARE THE DATE BITS IN THIS WORD..
	AND A,UFDIN+4
	IDIVI A,=31
	ADDI B,1
	CAIGE B,=10
	SGEN [ASCIZ / /]
	SPRINT =10,B
	IDIVI A,=12
	XCT MONTHS(B)
	ADDI A,=64
	SPRINT =10,A
	


GENTEX:	SPRINT 8,[-36]	;CRLF
	RECALL D↔RECALL C↔RECALL B↔RECALL A
	POPJ P,
SIZSPC:	;CRANK OUT ENOUGH SPACES
	PUSH P,A↔PUSH P,B
	TRNN F,%KMODE	;SKIP IF SIZES ≥ 1000 SHOULD BE PRINTED IN K
	JRST .+3
	CAIL A,=1000	;TURN THIS FIGURE INTO K WDS?
	JRST [	IDIVI A,=1000
		MOVEI B,
		SUBI B,2
		JRST SIZSP1] ;WHEN K'ING " K" TAKES 2 POSITIONS
	MOVEI B,	;B IS NUMBER OF SPACES TO TYPE AFTER THIS COMP
SIZSP1:	CAIGE A,=10	;ADD ONE TO B FOR EACH CHR. POSITION NOT PRINTED BY SPRINT
	ADDI B,1
	CAIGE A,=100
	ADDI B,1
	CAIGE A,=1000
	ADDI B,1
	CAIGE A,=10000
	ADDI B,1
	CAIGE A,=100000
	ADDI B,1
	JUMPL B,FATL05	;NUMBER SOOPER MOBY (LIKE ≥ 10000 K ! )
FAL05R:SIZLOP:	SOJL B,SIZEND	;PRINT B SPACES TO ADJUST RIGHT NUMBER
	SGEN [ASCIZ / /]
	JRST SIZLOP
SIZEND:	POP P,B↔POP P,A↔POPJ P,



COMMENT ⊗ Sort the files ⊗
SORT:	SAVE A↔SAVE B↔SAVE C↔SAVE D
	MOVEI A,	;POINTER TO UPPER FILES CONSIDERING
	TRNN F,%ORDER	;SKIP IF SHOULD BE REVERSE SORTING
	SKIPA I,ZERO	;INS. THAT CARE WILL XCT IDX OF THIS
	MOVEI I,1	; ""
SORTL:	MOVE B,FILES(A)	;GET FIRST OF THEM
	MOVE C,FILES+1(A)	;AND 2ND
	CAME B,[-1]	;WE RUNNING INTO END OF FILES?
	CAMN C,[-1]
	JRST SORTE	;YES, LETS FLUSH
	JRST ABCSKP	;DO THE DIRTY WORK.  COMPARE DATES OR FILENAMES OR NATURAL JUICES
SORTE:	POP P,D↔POP P,C↔POP P,B↔POP P,A
	POPJ P,

;SKIP COMMENTS APPLY TO FOWARD SORT (I CONTAINS 0)
ABCSKP:	TRNE F,%SZSRTS	;SKIP IF WE ARE NOT TO SORT BY SIZE
	JRST [	HLRZ D,B;B CONTIANS THE FILES WORD, WHOSE LEFT HALF IS THE FILE SIZE
		HLRZ E,C;C CONTIANS THE SECOND FILES WORD...
		JRST ABCGO	;DO ALL THAT THERE SKIP STUFF
		]
	TRNE F,%SORT
	JRST ABCDAT
	TRNN F,%XTSRT	;SKIP IF WE ARE TO SORT BY EXTENTION BEFORE FILE NAME
	SKIPA D,UFD(B)	;GET FFNAM OF FIRST FILE
	 HLLZ D,UFD2(B)	;THE LOW HALF IS GARBAGE
	TLC D,400000	;THEY ARE SIXBIT, TO BE SORTED
	TRNN F,%XTSRT	;DIRECT IF EXTENSION IS TO BE MORE SIGNIFICANT THAN FILE NM
	SKIPA E,UFD(C)	;GET FFNAME OF SECOND FILE
	 HLLZ E,UFD2(C)
	TLC E,400000
	JRST ABCGO
ABCDAT:	MOVE D,DATES(B)	;GET DATES FOR FIRST AND SECOND FILE
	MOVE E,DATES(C)
ABCGO:	XCT [CAMG D,E  ↔ CAML D,E](I) ;SKIP IF THESE TWO ARE OUT OF ORDER
	JRST ABC1
SWAP:	MOVEM B,FILES+1(A)	;PUT THEM BACK SWITCHED
	MOVEM C,FILES(A)
	CAIE A,
	SOJA A,SORTL	;AFTER SWITCHING FILES, SEE IF NEEDS TO BE DONE AGAIN
	AOJA A,SORTL	; ALREADY GOT THIS GUY TO THE TOP, CAN'T MOVE HIM UP AGAIN..
ABC1:	TRNN F,%SZSRTS	;SKIP IF WE ARE SORTING BY SIZE
	TRNE F,%SORT	;ONLY IF WE ARE IN FILENAME MODE...
	AOJA A,SORTL	;(OTHERWISE LOOP)
	CAME D,E	;IF THEY ARE EQUAL WILL HAVE TO LOOK AT EXTENSIONS
	AOJA A,SORTL	;NO, THEY DON'T NEED TO BE SWAPPED, NEXT PAIR
	TRNE F,%XTSRT	;DIRECT FOR SORT BY EXT. (GET FILENAME HERE, LOW ORDER WD.)
	SKIPA D,UFD(B)
	MOVE D,UFD2(B)	;GET 2FNAME OF FIRST FILE
	TLC D,400000
	TRNE F,%XTSRT
	SKIPA E,UFD(C)
	MOVE E,UFD2(C)	;GET 2FNAME OF SECOND FILE
	TLC E,400000
	XCT [CAMG D,E ↔ CAMLE D,E](I)	;SKIP IF TOP IS GREATER, MEANS NEED TO SWAP THEM
	AOJA A,SORTL	;OH WELL, THEY DONT NEED TO BE SWAPPED
	JRST SWAP
COMMENT ⊗ Switch Code ⊗

RDONLY:	TROE F,%READONLY;GO INTO READONLY MODE, SKIP IF WE MUST REDISPLAY
	JRST RIHANG
	TRNN F,%START
	JRST RIHANG
	JRST FCYCLE

READW:	TRZN F,%READONLY;GO INTO READWRITE MODE, SKIP IF WE MUST RE DISPLAY
	JRST RIHANG
	TRNN F,%START
	JRST RIHANG
	JRST FCYCLE

LKPCF:	;THE /LOOKUP SWITCH, FOR GETTING FULL DISPLAY ON FILES
	TRNN F,%START	;DIRECT IF WE GETTING THIS FROM MONITOR COMMAND LINE
	JRST RIHANG	;I DONT HAVE TO TAKE THAT FROM YOU
	SETOM ANYWHO	;INDICATE TO WORLD THAT AT LEAST ON FILES HAS BEEN LOOKED UP
	MOVE A,CURFIL	;HERE WE HAVE IT, THE CURRENT FILE'S NUMBER
	MOVE A,FILES(A)	;CURFIL IS FILES IDX.  FILES WORDS HAVE UFD IDX...
	SETZM FULWHO(A)	;0 MEANS THIS FILE IS IN FULL MODE, THIS WILL 'LOOK IT UP'
	SWGARD FCYCLE	;OKAY...

SZSRTS:	;PROCESS THE /SIZE SORT SWITCH
	TRO F,%SZSRT	;TURN ON THE SORT BY SIZE BIT
	SWGARD SCYCLE	;A GARDEN FOR FRESH NATURAL SWITCHES FOR YOU DINING PLEASURE

FFASTM:	TRO F,%FAST
	;ANY CHANGE IN THE MTHD. FOR ENTERING FAST MODE MUST BE REFLECTED AT GO
	SETZM ANYWHO	;THIS MEANS THERE ARE NO FULL FILES IN THE ENTIRE WORLD! [THEY AINT HARD TO CONVINCE]
	SETOM FULWHO	;TELL WORLD ALL FILES ARE IN FAST MODE, ALTHOUGH THAT MAY BE A LIE
	MOVE A,[FULWHO,,FULWHO+1]
	BLT A,FULWHO+NFILES-1
	SWGARD FCYCLE
	
FFULM:	TRZN F,%FAST	;GO INTO FULL MODE, DIRECT IF WE WERE IN FAST MODE BEFORE
	JRST RIHANG
	TRNN F,%START	;DIRECT IF WE READING MONITOR COMMAND LINE
	JRST RIHANG
	PUSH P,[SCYCLE]	;RETURN TO OCYCLE THERE
	JRST REASIZ	;THIS IS A PART OF READ UFD WHICH DOES ALL THE LOOKUPS
	
SHOWU:	TRC F,%DDELS	;CHANGE DISPLAY MORE, DELETE LIST, OR FILES
	TRNN F,%START	;DO THE STANDARD THING
	JRST RIHANG
	TRNE F,%DDELS	;SKIP IF WE HAVE JUST RETURNED FROM DELETE LIST MODE
	JRST SHW1
	PUT CURFIL,CURFIS	;SET UP CURFIL WITH OLD VALUE
	PUT DIPFIL,DIPFIS
	MOVE A,TFILES		;HERE IS WHERE WE HID TFILE WHEN WE GOT INTO THIS MODE
	MOVEM A,TFILE
	SUBI A,1
	MOVEM A,TFILE1
	JRST SHWE
SHW1:	PUT CURFIS,CURFIL	;SAVE SCREEN INFORMATION WE NOW HAVE
	SETZM CURFIL		;AND  GO TO TOP FOR SHOWING DELETE LIST
	PUT DIPFIS,DIPFIL
	SETZM DIPFIL
	PUT TFILES,TFILE
	MOVEI A,	;FIND OUT THE HIGHEST IDX INTO DELETE LIST
	SKIPE DELIS0(A)
	AOJA A,.-1
	MOVEM A,TFILE1
	ADDI A,1
	MOVEM A,TFILE	;SAVE IT SO DISPLAY FROBERS WONT OVERSHOOT
SHWE:	TRNN F,%RRUFD	;MUSTH RE-READ UFD FLAG
	JRST FCYCLE
	JRST RCYCLE
	
EXTSRT:	TRZ F,%SZSRTS	;ITS JUST ABOUT TIME THAT YOU GOT OVER YOU SIZE HANGUP
	TRZN F,%SORT	;SET SORT BY ALPHA
	TRCA F,%XTSRT	;SO WE WILL SORT BY EXT FIRST WHEN 1
	TRO F,%XTSRT	;GET HERE IF SORT WAS BY DATE WHEN THIS COMMAND TYPED
			; AND INSIST ON EXT. SORT, NOT COMPLEMENT
	TRNN F,%START	;DIRECT IF THIS IS FROM A COMMAND LINE
	JRST RIHANG
	TRO F,%NOOK	;DONT BOTHER USER WITH "OK" MESS
	TRNN F,%RRUFD;UNLESS ...
	JRST SCYCLE	;AND CYCLE THRU FROM SORT
	JRST RCYCLE  ;WE HAVE TO DO WIDE CYCLE

KMODC:	TRC F,%KMODE	;CHANGE THE KMODE
	TRO F,%NOOK	;DON'T BOTHER THE USER WITH AN OK FOR THIS
	TRNN F,%START	;DIRECT IF THIS IS COMMING FROM A COMMAND LINE
	JRST RIHANG
	TRNE F,%RRUFD	;IF WE GOT HERE AFTER TAKING A FILE NAME
	JRST RCYCLE	;THEN WE CANT FORGET TO RE READ THE UFD
	PUSHJ P,PUTUP	;THIS IS NONKJ-STANDARD, BUT IT PREVENTS ARROW FROM
	JRST OCYCLE	;BEING RE-DRAWN FOR NO GOOD REASON

RVSRT:	TRC F,%ORDER	;CHANGE ORDER FILES SORTED IN
	TRNN F,%START	;DIRECT IF TAKING SWITCHES FROM COMMAND LINE
	JRST RIHANG ;GET SOME MORE
	TRNN F,%RRUFD	;IF WE HAVE REC. A FILE NAME MUST RCYCLE
	JRST SCYCLE	;RE-SORT AND DISPLAY
	JRST RCYCLE


UDPMOD:	TROA F,%UDP	;SET UDP BIT
DSKMOD:	TRZA F,%UDP
	SKIPA A,['UDP   ']	;PUT THE NEW DEVICE NAME IN A
	MOVSI A,'DSK'
	;THIS MESS PUTS THIS DEVICE NAME IN THE INITS' DEVICE WORDS
	ZZZ←←0
	FOR @! ZZ←0,9,1	<  ;CLOBBER ALL THE LOSS!# 'S (NO .ISTOP! IN LOSING FAIL)
		IFE ZZZ,<	;IF THE LAST GUY WE HACKED WAS DEFINED
			IFDEF LOSS!ZZ,<	;AND THIS NEXT GUY EXISTS
				MOVEM C,LOSS!ZZ	;SAVE THIS AWAY
				>	;IFDEF THIS GUY
			IFNDEF LOSS!ZZ,<	;HAVE WE HIT THE END OF THE LINE
				ZZZ←←1	;YEP, MAKE THE REST OF THIS FLY BY FASTER
			>	;IFNDEF
			>	;IFE ZZZ
			>	;LOSING FOR

	TRNN F,%START	;SKIP IF THIS IS A MONIT. COM. LINE SWITCH
	JRST RIHANG	;CHECK THIS OUT
	JRST RCYCLE

RUNDEL:	;RUN DELETE LIST
	TRNN F,%START	;ARE WE REALLY RUNNING, OR IS THIS A SWITCH
	JRST RIHANG	;FOO, YOU CANT TYPE THIS AS A SWITCH
	PUSHJ P,XITING
	TRNE F,%RRUFD	;DO WE HAVE TO DO WIDE CYCLE? DIRECT IF T
	JRST RCYCLE
	TRNE F,%DDELS	;DIRECT IF IN DELETE LIST MODE
	JRST FCYCLE	;WILL HAVE TO PUT UP NEW DISPLAY
	JRST OCYCLE

DEBGM:	TRO F,%DEBUG	;PUT US IN DEBUG MODE
	TRNN F,%RRUFD	;WERE WE SUPPOSED TO GET ANOTHER PPN OR DEVICE
	JRST RIHANG
	JRST RCYCLE	;YEP

ABORT:	SETZM ARGSGN	;ALL WE NEED TO DO IS SIMULATE A -∞ DELETE
	SETOM ARGF
	MOVEI A,NFILES	;WE REGARD NFILES AS INF.
	MOVEM A,ARG	;YOU PUT OUR NATIONAL BIRD IN THE OVEN?
	JRST UNDEL	;I BET I FORGET TO CHANGED THIS REF TO UNDEL IF I HAVE TO
			;CHANGE UNDEL

DATESR:	TRZ F,%SZSRTS	;TV-36
	TRO F,%SORT	;SET SORT BY DATE FLAG
	TRNN F,%START
	JRST RIHANG
	TRNN F,%RRUFD
	JRST SCYCLE
	JRST RCYCLE
;	INSKIP		;ARE THERE ANY CHRS LEFT TO BE DECODED?
;	TRNE F,%START
;	JRST RIHANG
;	JRST RCYCLE

ALPHAS:	TRZ F,%SZSRTS	;SIZE AIN'T EVERYTHING
	TRZ F,%SORT	;SET SORT BY ALPHA
	TRZ F,%XTSRT	;RESET EXTENSION SORT SWITCH
	TRNE F,%START
	JRST SCYCLE
	TRNN F,%RRUFD
	JRST RIHANG
	JRST RCYCLE
;	INSKIP
;	TRNE F,%START
;	JRST RIHANG
;	JRST RCYCLE
COMMENT ⊗ Print a bit of this file ⊗
PRIFIL:	DPYPOS 1000-<4*14.>
	DPYSIZ <4*1000+<NLINES+2>/4>>
	...
COMMENT ⊗ Read PPN ⊗
RPPN:	SETZM CURFIL
	SETZM DIPFIL
	SETZM CURFIS
	SETZM DIPFIS
	MOVE A,LUSER
	SETZM RPPNF#
RRPPN:	MOVE B,[440600,,SYLAB]
RPPN2:	SETZM PPNCCT
RPPN2A:	INCHWL C
	CAIN A,"∀"
	MOVEI A,"?"
	CAIN C,","
	JRST RPPN1
	CAIN C,"*"
	JRST RPPN5
	CAIN C,12
	JRST RPPN2
	CAIE C,"["
	CAIN C," "
	JRST RPPN2
	CAIE C,"/"
	CAIN C,"]"
;	JRST RPPN3	;WE NOW EXIT (AT COMMAND LINE LEVEL) TO SETMASK, WHO REMOVES LF
	JRST [SNEAKW C, ↔ CAIE C,15 ↔ JRST RPPN3 ↔ INCHRW  ↔ JRST RPPN3 ]
	;CONDITIONALY TAKE THE CHR FOLLOWING A "]" OUT OF THE INPUT BUFFER CR→YES,  ELSE NO
	CAIN C,15
	JRST RPPN3
	CAIL C,141
	CAILE C,172
	XORI C,40
	IDPB C,B
	AOS PPNCCT
	JRST RPPN2A
RPPN5:	CAMN B,[220600,,SYLAB]
	JRST RPPN2A
	MOVEI C,'?'
	IDPB C,B
	AOS PPNCCT
	JRST RPPN5
RPPN1:	MOVE C,PPNCCT↔MOVE D,SYLAB
RPPN12:	CAIL C,3
	JRST RPPN11
	lSH D,-6
	AOJA C,RPPN12
RPPN11:	HLL A,D
	SETOM RPPNF#↔JRST RRPPN
RPPN3:	MOVE C,PPNCCT↔MOVE D,SYLAB
RPPN31:	CAIL C,3
 	JRST RPPN32
	LSH D,-6
	AOJA C,RPPN31
RPPN32:	SKIPN RPPNF#
	JRST [HLL A,D↔JRST RPPN33]
	HLR A,D
RPPN33:	TRNN F,%START	;DIRECT IF WE ARE READING A MONIT. COMMAND LINE
	JRST RPPN34	;SAVE NEW PPN AND WIN
RPPN34:	MOVEM A,LUSER	;NOW SAVE NEW LUSER
	TRNN F,%START	;AND FIGURE OUT HOW TO GET OUT OF HERE
	JRST RIHANG	;THIS WAS FROM MONITOR COMMAND LINE, TOP LEVEL NOS WHT TO DO
	TRO F,%RRUFD
	JRST RCYCLE
	
PPNCCT:	0↔SYLAB:BLOCK 2
COMMENT ⊗ Read a Mask ⊗
SETMAS:	;READ FROM TTY TO SET MASK
	TRO F,%RRUFD	;SO EXIT CRUD (SWITCH, ETC ) WILL RE READ UFD
	SETOM MMASK	;DEFAULT MASK TO MATCH ANY FILE
	MOVE A,[MMASK,,MMASK+1]
	BLT A,MMASK+8
	TRNE F,%START	;SKIP IF THIS IS COMMING FROM MONIT COMMAND LINE
	OUTSTR [ASCIZ / Mask: /]
	SETZM CURFIL	;SET ALL DISPLAY PARAMS TO BE LOOKING AT THE TOP
	SETZM DIPFIL
	SETZM CURFIS	;THESE ARE THE HIDDEN OLD DIP PARAMS
	SETZM DIPFIS	;FOR %DDELS MODE
	MOVEI B,	;THIS WILL BE USED AS IDX TO MUNG MMASK
MASKL:	INCHWL A
	CAIE A,"/"	;ARE WE REALLY READY TO READ A SWITCH 
	CAIN A,"["	;OR IS THIS AN AREA NAME?
	 JRST MASFLS	;WELL, TELL THE WORLD..
	CAIN A,":"	;DEVICE NAME
	 JRST MASDEV	;OOPS!  WE'VE BEEN TAKING A DEVICE NAME AS A MASK
	CAIN A,12	;LF MEANS RPPN STOLE CR FROM BUFFER, NO MORE TO DO
	 JRST RCYCLE
	CAIN A,15	;CR MEANS WE ARE COMPLETELY THRU READING COMMAND LINE
	 JRST MASFLS	;SO LET TOP LEVEL GET US STARTED AFTER THE LF
	CAIN A,"*"	;MEANS FILL OUT THIS FILE NAME WITH 'MATCH ANY CHR'S'
	 JRST MASK1
	CAIN A,"."	;MEANS MOVE ON TO NEXT FILE, FILL OUT TO END WITH SPACES.
	 JRST MASK2
	CAIN A,"↓"	;THIS GUY!  QUOTE THESE
	 JRST MASK3
	CAIE A,"∀"	;MATCH ANY CHR
	CAIN A,"?"	;MATCH ANY CHR
	 JRST MASK4
	CAIN A," "	;DONT LISTEN
	 JRST MASKL
	CAIN B,9	;IF WE HAVE ALREADY WRITTEN UP TO END OF MASK
	 JRST MASKL	;FORGET ABOUT EXTRA CHRS
	CAIGE A,140	;MAKE SIXBIT OUT OF THIS
	XORI A,40
	TRZ A,777700	;TURN THEM OFF IN CASE IT WAS LOWER CASE
	MOVEM A,MMASK(B)	;WHO WAS THAT MAN?
	AOJA B,MASKL

MASFLS:	CAIN B,		;IS THE MASK COMPLETELY VIRGIN
	JRST MASF1	;YEP, NOW GO TO RPPN, SWITCH, OR RIHANG
MASF0:	CAIN B,9	;OK, A MASK SET, NOW WIPE TO END WITH SPACES THEN FLS
	JRST MASF1
	SETZM MMASK(B)
	AOJA B,MASF0

MASF1:	CAIN A,"/"	;AH HA!  A SWITCH IAS BOTHERING US
	JRST SWITCH
	CAIN A,"["	
	JRST RPPN
	CAIE A,15
	JRST MASHUH	;HUH? WHAT BROUGHT US HERE
	TRNN F,%START	;DIRECT IF WE ARE READING A COMMAND LINE
	JRST RIHANG	;CR, NOW READ UFD AND ET...
	JRST RCYCLE	;RE-READ UFD
MASHUH:	PUSHJ P,CLEAR	;THIS IS FUNNY
	OUTSTR [ASCIZ /
Funny, I can't figure out why I was called.  Yours Truly, MASKed READER
/]↔	OUTCHR A	;OUTPUT THE CHR 
	exit

MASK1:	CAIN B,6	;IF WE ARE AT END OF FIRST FILE WHEN WE COME IN HERE
	JRST .+4	; IT MEANS  FILL OUT SECOND FILE NAME
MASK10:	CAIE B,6	;ARE WE ALREADY AT END OF FIRST, OR SECOND FILE
	CAIN B,9
	JRST MASKL
	SETOM MMASK(B)	;CLOBBER THIS ONE TO MATCH ANY CHR
	AOJA B,MASK10
MASK2:	CAIE B,6	;MAKE REST OF CHRS IN THIS FILE NAME SPACES 
	CAIN B,9
	JRST MASKL	;MADE IT
	SETZM MMASK(B)	;ZERO IS SPACE
	AOJA B,MASK2
MASK3:	INCHSL A	;READ SOME QUOTED CHARACTERS
	ERR	0,<No characters in buffer in ↓'s while reading mask.>
	CAIN A,"↓"
	 JRST MASKL	;GLAD THAT'S OVER
	CAIE A,"∀"	;THIS MEANS SAME AS ?, BUT IS NOT SIXBIT SO CAN BE
	 JRST MASK31
	SETOM MMASK(B)	; USED IN QUOTES
	AOJA B,MASK3
MASK31:	CAIGE A,140
	XORI A,40
	TRZ A,777700	;TURN OFF THIS CRAP INCASE IT WAS LOWER CASE
	MOVEM A,MMASK(B)	;YUM
	AOJA B,MASK3
MASK4:	SETOM MMASK(B)	;THIS WAS A "?"
	AOJA B,MASKL

MASDEV:	;GET HERE WHEN A : IS TYPED WHILE READING A MASK, TAKE CHR OUT OF MASK TO
	;GETSET'S DEVICE FROBS
	PUSH P,A ↔ PUSH P,C ↔ PUSH P,D
	MOVSI A,-6
	MOVEI C,
	MOVE B,[440600,,C]	;ASSEMBLE DEVICE NAME IN C
MASDVL:	MOVE D,MMASK(A)	;GET A CHR WHICH SHOULD HAVE GONE TO DEVICE NAME
	CAIGE D,	;SKIP IF THIS LOOKS LIKE A REAL CHR
	JRST MASDV1
	IDPB D,B	;STUFF IT IN C
	AOBJN A,MASDVL
	ZZZ←←0		;LOSING FAIL.  HERE'S WHERE ALL THE TIME IS GOING
MASDV1:	FOR @! ZZ←0,9,1	<  ;CLOBBER ALL THE LOSS!# 'S (NO .ISTOP! IN LOSING FAIL)
		IFE ZZZ,<	;IF THE LAST GUY WE HACKED WAS DEFINED
			IFDEF LOSS!ZZ,<	;AND THIS NEXT GUY EXISTS
				MOVEM C,LOSS!ZZ	;SAVE THIS AWAY
				>	;IFDEF THIS GUY
			IFNDEF LOSS!ZZ,<	;HAVE WE HIT THE END OF THE LINE
				ZZZ←←1	;YEP, MAKE THE REST OF THIS FLY BY FASTER
			>	;IFNDEF
			>	;IFE ZZZ
			>	;LOSING FOR
	CAMN C,['UDP   ']
	TROA F,%UDP	;DO THE RIGHT THING IF HE WENT TO UDP
	TRZ F,%UDP
	SETOM MMASK	;NOW RESET MASK TO BE VIRGIN TERRA
	MOVE A,[MMASK,,MMASK+1]
	BLT A,MMASK+8
	TRNE F,%START	;IF WE ARE GETTING THIS DEVICE NAME FROM COMMAND LINE THEN
	JRST MASDV2
	MOVEI A,	;0 TO DSKPPN MEANS RETURN OWN
	DSKPPN A,	; DON'T USE THE PPN FROM TEMPCORE, BUT THE LUSERS DSKPPN
	MOVEM A,LUSER	;BUT IF DEVICE GIVEN WHILE RUNNING, HE PROBABLY WANT PPN
MASDV2:	POP P,D ↔ POP P,C ↔ POP P,A
	MOVEI B,
	JRST MASKL
COMMENT ⊗ Output Text to Random Device ⊗
OUTDT:	PUSHJ P,OUTDTI	;INITIALIZE
	PUSHJ P,OUTDTH	;OUTPUT HEADER
	PUSHJ P,OUTDTB	;OUTPUT BODY
	JRST OCYCLE

OUTDTA:	;FOONLY MODE, OUTPUT FILE NAMES WITH NO HEADERS
	PUSHJ P,OUTDTI	;INITIALIZE
	PUSHJ P,OUTDTF	;OUTPUT FOONLY MODE BODY
	JRST OCYCLE

OUTDTI:	INCHSL
	JFCL		;GET THE LF OUT OF INPUT BUFFER
	GETFIL (E,Output File Name  :,0,FIL,DELBLK,7,OUTDT)	;GARBAGES AC'S
	TRO F,%DEVUO	;SO TEXT UUO'S IN GENTXT WILL OUTPUT TO FIL CHAN
	POPJ P,

OUTDTH:	SGEN [ASCIZ /...... PPN = /]
	TYPE6 6,LUSER
	TRNE F,%FAST	;IN FAST MODE DONT TYPE DIRECTORY SIZE
	JRST OUTDT3
	SGEN [ASCIZ / ....... Total /]
	TYPE6 6,LOSS0	;THIS IS THE DEVICE NAME BEING EDITED ON
	SGEN [ASCIZ /Space used in words = /]
	SPRINT =10,WORDS
OUTDT3:	SGEN [ASCIZ / ......./]
	SPRINT 8,[-36]
	SKIPN ANYWHO	;DIRECT IF THERE ARE NO FULL MODE FILES
;	TRNE F,%FAST	;USE HEDLI2 WHEN IN FAST MODE
	SGEN @HEDLI2
	SKIPE ANYWHO	;DIRECT IF THERE IS AT LEAST ON FAST MODE FILE
;	TRNN F,%FAST	;USE NORMAL HEAD LINE OTHERWISE
	SGEN @HEDLIN	;HERE IS A SGEN WITH THE HEADER INFO "FILENAME  EXT...
	POPJ P,

OUTDTB:	MOVSI A,-NFILES	;AOBJN THRU FILE LIST GEN. TEXT OF FILES TO DEVICE
OUTDT1:	MOVE B,FILES(A)	;THIS IS THE FILE
	CAMN B,[-1]	;AS SOON AS WE FIND A -1 WE HAVE HIT E/O FILES LIST.
	JRST OUTDT2
	PUSHJ P,GENTXT	;GENTXT TAKES A TO BE INDX INTO FILES, NOT CLOBBERED
	AOBJN A,OUTDT1	;RUN THAT BY ME AGAIN?
OUTDT2:	SPRINT 8,[-36]
	CLOSE FIL,
	TRZ F,%DEVUO
	POPJ P,

OUTDTF:	;OUTPUT FOONLY MODE BODY
	MOVSI A,-NFILES	;AOBJN THRU FILE LIST, OUTPUTING FILE NAMES
OUTDF1:	MOVE B,FILES(A)	;THIS IS THE FILE
	CAMN B,[-1]	;-1 IS EO FILE LIST
	JRST OUTDF2
	PUSHJ P,GENNAM	;OUTPUT TO DEVICE A MACHINE READABLE FILE NAME
	SPRINT 8,[-36]
	AOBJN A,OUTDF1
OUTDF2:	CLOSE FIL,
	TRZ F,%DEVUO
	POPJ P,


GENNAM:	;GIVEN A INDEX INTO FILES LIST OUTPUT MACHINE READABLE FILE NAME
	PUSH P,A ↔ PUSH P,B
	MOVE B,FILES(A)	;GET UFD INDEX FOR THIS FILE
	MOVE A,UFD(B)	;GET FIRST FILE NAME
	PUSHJ P,GEN6B	;OUTPUT IT
	HLLZ A,UFD2(B)	;PICK UP EXT OF THIS FILE
	JUMPE A,GENNA1	;DONT BOTHER WITH ".EXT" IF NONE EXISTS
	SGEN [ASCIZ /./];. BETWEEN FILE.EXT
	PUSHJ P,GEN6B	;OUTPUT EXT OF THIS FILE
GENNA1:	SGEN [ASCIZ /[/]
	HLLZ A,LLUSER(B);GET PROJECT NAME
	PUSHJ P,GEN6P
	SGEN [ASCIZ /,/]
	HRLZ A,LLUSER(B)
	PUSHJ P,GEN6P
	SGEN [ASCIZ /]/]
	POP P,B ↔ POP P,A ↔ POPJ P,

GEN6P:	PUSH P,A ↔ PUSH P,B ↔ PUSH P,C
	MOVE C,[440600,,A]	;SIXBIT BYTE POINTER INTO PROJECT OR PROGRAMMER NAME
REPEAT 3,<
	ILDB B,C	;GET A CHAR
	JUMPE B,.+3
	ROT B,-6	;PLACE THIS SIXBIT CHAR IN CORRECT PLACE
	TYPE6 1,B
	>;REPEAT 3
	POP P,C ↔ POP P,B ↔ POP P,A ↔ POPJ P,

GEN6B:	PUSH P,A ↔ PUSH P,B ↔ PUSH P,C
	MOVE C,[440600,,A]
REPEAT 6,<
	ILDB B,C	;GET A CHAR
	JUMPE B,GEN6B1	;SPACE INDICATES END OF ROAD
	ROT B,-6
	TYPE6 1,B
	>;REPEAT 6
GEN6B1:	POP P,C ↔ POP P,B ↔ POP P,A ↔ POPJ P,
COMMENT ⊗ Files Spooled Here.  No cost, no obligation ⊗
SPOOLR:	;THIS GETS CALLED AS A SWITCH, SPOOL ARG FILES
	MOVE Q,[-QPDS,,QPDL-1]
	TRNN F,%START	;DIRECT RETURN IF THE LUSER TYPED THIS IN COMMAND LINE
	JRST RIHANG
	ARGET A,1,CJRST4	;GET THE ARG
	MOVSI A,(A)		;USE ARG AS AOBJN COUNT
	HRR A,CURFIL		;GET THE FILES INDEX TO START FROM IN RIGHT
SPOOLL:	MOVE B,FILES(A)		;THIS GIVES THE UFD INX FOR THE CURRENT FILE
	CAMN B,[-1]		;DIRECT IF WE HAVE HIT THE BOTTOM OF THE BAR.
	JRST SPOLLE
	MOVE D,UFD(B)		;THIS HERE SHOULD BE THE FIRST FILE NAME TO SPOOL
	MOVEM D,SPLBLK		;FOR SPOOLM
	HLLZ D,UFD2(B)		;THE LEFT HALF IS THE EXT
	MOVEM D,SPLBLK+1
	MOVE D,LLUSER(B)	;GET THE PPN OF THIS FILE
	MOVEM D,SPLBLK+3
	EXTERN SPOOLM,SPL%CN
	PUSHJ Q,SPOOLM
	JUMP SPLBLK		;I GUESS SPOOLM LOOKS HERE FOR THE  ADDS.
	AOBJN A,SPOOLL		;GO DO THIS FOR MORE LUSER FILES
SPOLLE:	SWGARDEN RIHANG		;QREWPOUI

	
COMMENT ⊗
For FAIL and Macro programs the calling sequence is:

	EXTERN	SPOOLM,SPL%CN
	PUSHJ	17,SPOOLM
	JUMP	ARGS

where  ARGS  is  the address of a four word lookup block that has the
appropriate flags in the right half of ARGS+1. The IO channel that is
used  may be selected by setting the external variable SPL%CN to some
number which will be used (mod 20 octal) as  the  channel  number  to
use.  The default is channel 17.  The address of ARGS may be anywhere
in your core, except that if you use the accumulators for  ARGS, then
ARGS must  be smaller than 14 so that all four words will fit beneath
17.  As a programming convenience, all accumulators will be  restored
by this routine to their original values.
All programs:

The flags have the following significance:

Octal	Bit		Meaning
1	(bit 35)	delete this file after listing
2	(bit 34)	do fortran carriage control
4	(bit 33)	use LPT mode 101 instead of mode 1.
10	(bit 32)	delete SOS line numbers
20	(bit 31)	print headings at the top of each page
40	(bit 30)	suppress the title page.
100	(bit 29)	make narrow title page for 8.5" paper
200	(bit 28)	list data as octal words.
400	(bit 27)	suppress message announcing "spooling done"
1000	(bit 26)	convert all line feeds to '177&'21.
⊗

COMMENT ⊗ FNR for /OUTPUT command ⊗
;READ FILE SPECS FROM TTY INTO BLOCK
;WORD AFTER CALL IS DEFAULT EXTENSION,,BLK ADDRESS.
;DOESNT SKIP IF ALT MODE TYPED.
;SKIPS ONCE IF SYNTAX ERROR, TWICE IF OK.
FILSCN:	MOVE L,@(P)
	HLLZM L,1(L)	;SET UP DEFAULT EXTENSION
	AOS (P)
	MOVE I,SAVPPN
	MOVEM I,3(L)	;INITIALIZE TO CURRENT DSK PPN
	PUSHJ P,GETSIX	;SYMBOL IN J, SEPARATOR IN I
	CAIN I,175	;ALT MODE
	POPJ P,
	AOS (P)
	MOVEM J,(L)
	CAIN I,"."
	JRST FILSCX	;GET EXTENSION
	CAIN I,"["
	JRST FILSCP	;GET PPN
	CAIN I,12
POPJ1:	AOS (P)
	POPJ P,

FILSCX:	PUSHJ P,GETSIX
	HLLZM J,1(L)
	CAIN I,12
	JRST POPJ1
	CAIE I,"["
	POPJ P,
FILSCP:	PUSHJ P,GETSIX
	JUMPE J,FILSP3
FILSP1:	TLNE J,77	;RIGHT ADJUST
	JRST FILSP2
	LSH J,-6
	JRST FILSP1

FILSP2:	HLLM J,3(L)	;STORE PROJ NUMBER
FILSP3:	CAIN I,","
	JRST FILSP4	;GET PROGRAMMER NAME
FILSP8:	CAIN I,"]"
	JRST FILSP5	;DONE
	CAIN I,12
	AOS (P)
	POPJ P,

FILSP4:	PUSHJ P,GETSIX
	JUMPE J,FILSP8
FILSP6:	TLNE J,77
	JRST FILSP7
	LSH J,-6
	JRST FILSP6

FILSP7:	HLRM J,3(L)
	JRST FILSP8

FILSP5:	PUSHJ P,GETSIX
	CAIN I,12
	JRST POPJ1
	JRST FILSP5

LUPFL:	OUTSTR [ASCIZ /LOOKUP FAILED - /]
	MOVEI L,LUP
FILNOU:	MOVE I,(L)
	PUSHJ P,SIXTYP
	OUTCHR ["."]
	MOVE I,1(L)
	PUSHJ P,SIXTY3
	OUTCHR ["["]
	MOVE I,3(L)
	PUSHJ P,SIXTY3
	OUTCHR [","]
	MOVS I,3(L)
	PUSHJ P,SIXTY3
	OUTSTR [ASCIZ /]
/]
	POPJ P,

ENTFL:	OUTSTR [ASCIZ /ENTER FAILED - /]
	MOVEI L,ENT
	JRST FILNOU

;GET SIXBIT SYLLABLE IN J WITH SEPARATOR IN I
GETSIX:	MOVE K,[440600,,J]
	MOVEI J,0
GETSX1:	INCHWL I
	CAIN I,15
	JRST GETSX1
	CAIL I,"0"
	CAILE I,"9"
	JRST GETSX2	;NOT NUM
	JRST GETSX3	;NUMBER
GETSX2:	CAIL I,"a"
	CAILE I,"z"
	JRST GETSX4	;NOT LOWER CASE
	JRST [	SUBI I,40	;LOWER CASE
		JRST GETSX3]
GETSX4:	CAIL I,"A"
	CAILE I,"Z"
	POPJ P,
GETSX3:	SUBI I,40
	TLNE K,770000
	IDPB I,K
	JRST GETSX1

;TYPE I IN SIXBIT (6 CHARS WORTH)
SIXTYP:	MOVE J,[440600,,I]
SIXTY1:	ILDB K,J
	ADDI K,40
	OUTCHR K
	TLNE J,770000
	JRST SIXTY1
	POPJ P,

;TYPE LEFT 3 CHARS OF I
SIXTY3:	MOVE J,[440600,,I]
SIXTY4:	ILDB K,J
	ADDI K,40
	OUTCHR K
	TLNE J,500000
	JRST SIXTY4
	POPJ P,

INITL:	OUTSTR [ASCIZ /CAN'T INIT DSK - LOSEY, LOSEY
/]
	JRST 4,.
SAVPPN:	0		;HAS CURRENT DSK PPN
LUP:	BLOCK 4
ENT:	BLOCK 4

COMMENT ⊗ Trivia ⊗
RSCAN:	;READ MONITOR COMMAND LINE, AND DO ALL THE RIGHT THINGS WITH IT
	PUSH P,A
	RESCAN
RSCAN1:	INCHRW A	;KEEP READING UNTIL FIRST CHR
	CAIL A,"A"	;THROW OUT NON A-Z AND a-z's
	CAILE A,"Z"
	JRST .+2	;MAY BE a-z
	JRST RSCAN2	;WE'VE GOT A 'WINNER'
	CAIL A,"a"
	CAILE A,"z"
	JRST RSCAN1
	SUBI A,40	;MAKE THIS LOWER CASE `WINNER' INTO SOMETHING WE CAN UNDERSTAND
RSCAN2:	CAIN A,"D"	;IF THE FIRST CHR IS A "D" THEN WE ARE READING A 'DRD' COMMAND
	JRST RSCAN3	;THIS MEANS THE FIRST NON A-Z a-z CHR IS WHERE TO STOP
		;WHEREAS THIS MEANS ; IS WHERE TO STOP
RSCAN4:	INCHRW A
	CAIE A,";"
	CAIN A,15	;OR A CR MEANS NO GARBAGE OF INTEREST, ANYWAY
	JRST RSCANE	;POPJ AND WHATNOT
	JRST RSCAN4	;OH WELL, THERES ONE OUT THERE SOMEWHERE
RSCAN3:	SNEAKW A,
	CAIL A,"A"	;SO THROW THESE OUT
	CAILE A,"Z"
	JRST .+2
	JRST [	INCHRW	;THROW THIS OUT
		JRST RSCAN3]
	CAIL A,"a"
	CAILE A,"z"
	JRST RSCNE2	;YUM!  THIS GUY THIS NOT A LETTER
	INCHRW		;THROW OUT THIS A-Z CHR
	JRST RSCAN3	;AND GET ANOTHER LUSER
RSCNE2:	CAIE A,"/"	;FLUSH THE BREAK CHR UNLESS IT IS /[*
	CAIN A,"["
	JRST RSCANE
	CAIE A,"*"
	INCHRW		;THROW THIS OUT
	;AND FALL THRU TO RSCANE
RSCANE:	;IF THERE IS ANYTHING ACTUALLY IN THE COMMAND LINE (OTHER THAN DRD ETC.)
	;THEN FLUSH CURFIL, DIPFIL, AND PPN.
	SNEAKW A,	;WE MAY FIND A LF OR CR HERE, OR SOME OTHER LOSSAGE
	CAIE A,12	;LF
	CAIN A,15	;OR CR?
	JRST [	POP P,A	;YEP, WELL, LEAVE IT TO BEAVER
		POPJ P,
		]
	SETZM CURFIL
	SETZM DIPFIL	;DO IN THESE TWO OLD FROBS
	MOVEI A,
	DSKPPN A,	;NOW FIND OUT WHAT THE GUY'S ALIAS IS
	MOVEM A,LUSER	;AND CLOBBER LUSER.  WE DOING THIS BECAUSE COMMANDS
			;ARE BEING GIVEN IN MONIT LINE.  WE DONT CLOBBER THE FLAGS
	SETOM MMASK	;NOW BLT *.* TO MASK
	MOVE A,[MMASK,,MMASK+1]
	BLT A,MMASK+8
	POP P,A
	POPJ P,

PRWHO:	PUSH P,A↔PUSH P,B
	MOVE A,[440600,,II]	;READ CHRS FROM LUSER LOC
REPEAT 6,{ILDB B,A↔ADDI B,40↔OUTCHR B}
	POP P,B↔POP P,A
	POPJ P,

ZCLEAR:	TRNE F,%TTY		;CLEAR IS A NOOP ON TTYS
	POPJ P,
	TRNE F,%GETTY		;ON III
	JRST [ PGACT ↔ POPJ P,]	;ON III
	SETOM DDSELP		;LET ↓↓ (THAT DOWN THERE) KNOW NOT TO CLEAR ECHO LINES
CLEAR:	TRNE F,%TTY		;DIRECT ON TTYS
	POPJ P,
	TRNE F,%GETTY		;ON III ONLY A ...
	JRST [ SETZM DDSELP ↔ DPYCLR ↔ POPJ P, ]	;IS NEEDED
	PUSH P,A↔PUSH P,B ↔ PUSH P,BP7
	DDUPG [200000,,DDFLSA↔5↔0↔DDFMUN]	;FLUSH OLD ARROW
	MOVEI A,1
	MOVEM A,DIRLIN
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[440700,,DIRLIN]
	MOVEM A,BP7
	SKIPN DDSELP	;THROUGH IN A FEW MORE FOR CLEARING ECHO LINES
	SKIPA A,[-<NLINES+4+5>,,]
	MOVSI A,-<NLINES+4>
CLEAR1:	sgen [asciz / 
/]↔	AOBJN A,CLEAR1
;	DDUPG [200000,,DDHEAD↔DIRLEN+3↔0↔DDMUNG]
	DDUPG DDCLR
	SKIPE DDSELP
	JRST .+3
	PPSEL
	PPSEL 2
CLEAR2:	SETZM DDSELP
	POP P,BP7 ↔ POP P,B↔POP P,A
	POPJ P,

DDCLR:	200000,,DDHEAD
	DIRLEN+3
	0
	DDMUNG


COMMENT ⊗ Temp core 

		TMPCOR file looks like

PPN
CURFIL,,DIPFIL
MMASK	;FOOBAR
MMASK
MMASK
MMASK
MMASK
MMASK	;.
MMASK	;BAZ
MMASK
MMASK
FLAGS	
DEVICE	;FROM LOSS0
⊗
NTPCW←←=13	;NUMBER OF TEMP CORE WORDS NEEDED


WTMPC:	PUSH P,A ↔ PUSH P,B
	MOVEI A,
	TMPCOR A,	;FIND OUT HOW MUCH FREE SPACE THERE IS
	ERR 0,<TMPCOR of 0 to read available space fails.  Find a wizard.>
	CAIGE A,NTPCW	;SKIP IF THERE IS ENOUGH ROOM FOR US
	JRST WTMPCE	;EXIT TO CALLER, WE CAN'T FIND ENUF SPACE
	MOVE A,LUSER	;NOW PREPARE BLOCK FOR WRITING TEMP CORE FILLE
	MOVEM A,TMPCBL
	MOVS A,CURFIL	;NEXT WORD ← CURFIL,,DIPFIL (DISPLAY WINDOW ON WORLD)
	HRR A,DIPFIL
	MOVEM A,TMPCBL+1
	MOVE A,[MMASK,,TMPCBL+2]	;PUT THE MASK WORDS OUT THERE
	BLT A,TMPCBL+2+8
	MOVEM F,TMPCBL+=11
	MOVE A,LOSS0	;THIS IS THE CURRENT DEVICE
	MOVEM A,TMPCBL+=12
	MOVE A,[  3,,[	'DRD',,
			-NTPCW,,TMPCBL-1]
		]	
	TMPCOR A,	;WELL, WRITE THIS HERE THING HERE
	ERR	0,<Tempcore write fails.>
	POP P,B ↔ POP P,A
	POPJ P,
WTMPCE:	POP P,B ↔ POP P,A
	OUTSTR [ASCIZ /(tmpcor file not written for lack of space)/]
	POPJ P,

RTMPC:	PUSH P,A ↔ PUSH P,B
	MOVE A,[	2,,[	'DRD',,
				-NTPCW,,TMPCBL-1]
		]
	TMPCOR A,	;GET THAT FILE BACK (IF IT EXISTS)
	JRST RTMPCE	;GO AWAY, ASSUME THE PROBLEM IS WE HAVE NO TEMPCORE FILE
	TRO F,%TCORE	;MEANS WE FOUND A FILE.  SO RANDOM THINGS WONT SET UP INTLS.
	;NOW START PUTTING THIS TEMPCORE DATA INTO DIRED
	MOVE A,TMPCBL
	MOVEM A,LUSER	;THIS WAS THE OLD PPN
	MOVE A,TMPCBL+1	;CURFIL,,DIPFIL
	HRRZM A,DIPFIL
	HLRZM A,CURFIL
	MOVE A,[TMPCBL+2,,MMASK]	;SET UP DAT MASK
	BLT A,MMASK+8
	MOVE A,TMPCBL+=11	;THESE ARE THE OLD FLAGS
	TRNE A,%SORT	;RESTORE ONLY THESE FLAGS
	TRO F,%SORT
	TRNE A,%FAST
	JRST [	TRO F,%FAST
		SETOM FULWHO	;WE ARE GOING INTO FAST MODE, PUT ALL THE FILES IN IT
		SETZM ANYWHO	;INDICATE THERE ARE NO FULL MODE FILES
		MOVE B,[FULWHO,,FULWHO+1]
		BLT B,FULWHO+NFILES-1
		JRST .+1	;LEAVING THIS OUT CAUSES NICE OBSCURE BUG. (I KNOW)
		]
	TRNE A,%ORDER
	TRO F,%ORDER
	TRNE A,%DEBUG
	TRO F,%DEBUG
	TRNE A,%UDP
	TRO F,%UDP
	TRNE A,%KMODE
	TRO F,%KMODE
	TRNE A,%XTSRT
	TRO F,%XTSRT
	TRNE A,%SZSRTS
	TRO F,%SZSRTS
	MOVE A,TMPCBL+=12	;THIS IS THE OLD DEVICE NAME
	;THIS MESS STUFFS A IN ALL THE INIT DEVICE LOCATIONS
	ZZZ←←0
	FOR @! ZZ←0,9,1	<  ;CLOBBER ALL THE LOSS!# 'S (NO .ISTOP! IN LOSING FAIL)
		IFE ZZZ,<	;IF THE LAST GUY WE HACKED WAS DEFINED
			IFDEF LOSS!ZZ,<	;AND THIS NEXT GUY EXISTS
				MOVEM A,LOSS!ZZ	;SAVE THIS AWAY
				>	;IFDEF THIS GUY
			IFNDEF LOSS!ZZ,<	;HAVE WE HIT THE END OF THE LINE
				ZZZ←←1	;YEP, MAKE THE REST OF THIS FLY BY FASTER
			>	;IFNDEF
			>	;IFE ZZZ
			>	;LOSING FOR

RTMPCE:	POP P,B ↔ POP P,A
	POPJ P,

TMPCBL:	BLOCK NTPCW	;BLOCK FOR TEMP CORE OPERATIONS
COMMENT ⊗ To err is human, to forgive, Divine ⊗
FATL01:	PUSHJ P,CLEAR
	OUTSTR [ASCIZ /Fatal Error - GENTXT overshot DIRLIN at PUTL1
/]↔	SETZ↔EXIT
FATL02:	PUSHJ P,CLEAR
	TRNE F,%UDP	;DIRECT IN UDP MODE
	OUTSTR [ASCIZ /You better check out the UDP.  I can't INIT it./]
	TRNN F,%UDP	;FOR DSK MODE
	OUTSTR [ASCIZ /Can't INIT the /]
	TTY6 3,LOSS0	;TYPE THE DEVICE NAME WE ARE USING NOW
	OUTSTR [ASCIZ /.  Restart to try again./]
	EXIT

FATL03:	OUTSTR [ASCIZ /
PPN "/]
	PUSHJ P,PRWHO
	OUTSTR [ASCIZ /" Greedily Masticates.
Try Again:  /]
	MOVE P,[-PDS,,PDL-1]
	INCHRS	;TAKE ALL THE CHRS OUT OF INPUT BUFFER, ASSUME TYPED BEFORE ERR MSG
	JRST RPPN
	JRST .-2
FALT04:	PUSH P,A
	OUTSTR [ASCIZ /
Non Fatal Bug - CURFIL overshot Screen.  Report please.
/]↔	MOVEI A,
	BEEP A,
	POP P,A
	JRST PUTREC
FATL05:	OUTSTR [ASCIZ /
Non Fatal Error 105 - Right adjust fault. Please report. /]
	JRST FAL05R
FATL06:	PUSHJ P,CLEAR
	OUTSTR [ASCIZ /
Fatal Error 69.105!  Ran out of delete space.  You ought to remember what
you were doing and report this./]
	exit


FATL07:	OUTSTR [ASCIZ /
Not a display???  You lose./]
	exit

comment ⊗
FATL08:	PUSHJ P,CLEAR
	OUTSTR [ASCIZ /
You have a file named "←←←←←←".  Please rename it.
/]
	exit
⊗

FATL09:	OUTSTR [ASCIZ /
LOOKUP FAILED IN FLOOKUP UUO.  PROCEED WITH CAUTION!!/]
	JRST UUORET

COMMENT ⊗ Help a luser ⊗
HELP:	PUSH P,A ↔ PUSH P,B
	MOVEI A,1	;BLT 1'S TO DIRLIN
	MOVEM A,DIRLIN
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[440700,,DIRLIN]	;SET UP BP FOR UUOS
	MOVEM A,BP7
	TRNN F,%GETTY	;ONLY ON DD...
	PUSHJ P,ZCLEAR	;CLEAN UP DIRECTORY STUFF LI'IN ABOUT
	;DISPLAY THIS WHEN LUSER ASKS FOR IT, HELP ("?")
	TRNN F,%DDELS	;USE DIFFERENT HELP FOR DELETE LIST MODE
	SGENA [ASCIZ ≡

You are using Dired, a program that displays a directory of your
choosing, and permits you to modify it in various ways.  Files may be deleted,
edited, or renamed (soon) using Dired.

In command descriptions below α and β are used to mean Control and Meta
respectively.  Most commands take prefix arguments. Type arguments while
holding the Control and Meta keys.  eg. αβ-αβ6αβ9 is an argument of -69.

        These are the command for moving around in the display:
            (Same as E commands)
CR      Move down one line      BS      Move up one line
αβ<     Move down 1/8th screen  αβ>     Move up 1/8th screen
αβ≤     Move down 1/2 screen    αβ≥     Move up 1/2 screen
FORM    Down to next screenful  VT      Up to next screenful
αβT     Four more lines at top  αβB     Four more lines at bottom
αβJ     Jump line to top        αβ∧ and ∨ Cursor to top or bottom of window

        Here are the rest of the commands with brief descriptions:

αβD      Delete a file           αβE     Exit the Directory Editor
αβM      Reads a file mask       [       Reads a PPN
αβV      Redraws the screen      /HELP   Displays switch documentation
/EDIT    Enters E on the current file
/EXAMINE Enters E on the current file in /R mode.
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  ¬
             You may return to Dired from E by typing αXDRD<RETURN>

              More information is available in DIRED.SGK[UP,DOC]

                      Type αβV to get back to your files

≡]
	SGEN [ASCIZ ≡
You are in Delete List mode.  Enter it and leave it with the /SHOW
command.  The files shown here are ones which you have told Dired to
delete.  Files can be removed from this list by using the αβD command
in th same way you used it to get them here.

In command descriptions below α and β are used to mean Control and Meta
respectively.  Most commands take prefix arguments. Type arguments while
holding the Control and Meta keys.  eg. αβ-αβ6αβ9 is an argument of -69.

        These are the command for moving around in the display:

CR      Move down one line      BS      Move up one line
αβ<     Move down 1/8th screen  αβ>     Move up 1/8th screen
αβ≤     Move down 1/2 screen    αβ≥     Move up 1/2 screen
FORM    Down to next screenful  VT      Up to next screenful


        Here are some other commands:

αβM     Reads a file mask       [       Reads a PPN
αβV     Redraws the screen      αβD     Deletes entries from the delete list
/	Reads at least one switch (any number may be given)
/HELP   Displays documentation on the switches
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  ¬

     Type αβD to delete an entry displayed here from the delete list

             Type /SHOW<RETURN> to see your directory again

                Type αβV to get back to the Delete List
≡]
HELDO:	TRNE F,%GETTY
	JRST HELIII	;III DON'T THINK DD CAN HACK IT PHYLS.
	DDUPG [	200000,,DDHEAD
		DIRLEN+3
		0
		DDMUNG]
HELXIT:	POP P,B ↔ POP P,A
	JRST RIHANG
HELIII:	AOS A,BP7	;THIS GOT THE LOCATION WE WERE WRITING TEXT INTO LAST
	SUBI A,IIHEAD	;NO NEED TO DISPLAY INF. NULS ON III (FLICKER FLICKER)
	HRRZM A,IIIBLK+1	;THIS IS WHERE LENGTH OF PRG KEPT
	DPYOUT IIIBLK
	PGACT (<SETZ>)
	PGSEL
	JRST HELXIT

HELPSW:	PUSH P,A ↔ PUSH P,B
	MOVEI A,1	;BLT 1'S TO DIRLIN
	MOVEM A,DIRLIN
	MOVE A,[DIRLIN,,DIRLIN+1]
	BLT A,DIRLIN+DIRLEN-1
	MOVE A,[440700,,DIRLIN]	;SET UP BP FOR UUOS
	MOVEM A,BP7
	TRNN F,%GETTY	;ONLY ON DD...
	PUSHJ P,ZCLEAR	;CLEAN UP DIRECTORY STUFF LI'IN ABOUT
	;DISPLAY THIS WHEN LUSER ASKS FOR IT, HELP ("?")
	SGEN [ASCIZ ≡
These are the switches currently available in Dired.  Only enough of the
name of the switch to uniquely identify it need be typed.  Type αβV to get
back to what you were looking at before.  For more complete information see
DIRED.SGK[UP,DOC].

/ABORT     Clears the delete list.
/ALPHA     Dis plays the files sorted by file name.
/DATE      Displays the files sorted by date last written.
/DELETE    Runs the delete list.
/DSK MODE  Changes your device to DSK:.  Like typing αβM DSK:<CR>
/EDIT FILE Enters E on the current file.  Re-enter Dired by typing αXDI<CR>
/EXAMINE   Enters E on the current file in /R mode.
/EXTENSION Displays the files sorted by extension, then file name.
/F or FAST Puts you in fast mode.  No lookups are done when reading UFD's.
/FULL MODE Removes you from /F mode.  Displays dates, times, sizes, etc. of files.
/HELP      Displays this cruft.
/LOOKUP    Reads and displays full data for current file such as dates, size, etc.
/K MODE    Complements the way file sizes greater than 1024 are printed.
/OUTPUT    Writes all the directory information on the filename given.
/REVERSE   Displays the files in reverse order.  Sticky over other sort commands.
/SHOW      Switches display modes between delete list mode and the normal mode.
/SIZE SORT Sorts the files by size.
/SPOOL     Spools ARG files, starting with the current, on the LPT in /NOHEAD mode.
/UDP MODE  Changes the device to UDP:.
≡]
	TRNE F,%DDELS	;DIRECT IF IN DELETE LIST MODE
	SGENA [ASCIZ /
                 Type αβV to get back to the Delete List
/]↔	SGEN [ASCIZ /
                Type αβV to get back to your file display
/]
	JRST HELDO
COMMENT ⊗ UUO Handler ⊗
UUOH:	0
	MOVEM 17,UUOACS		;SAVE AC'S FOR UUOING
	MOVEI 17,UUOACS
	BLT 17,UUOACS+16
	LDB A,[331100,,40]	;GET OP CODE OF UUO
	CAILE A,LASUUO		;OP CODE OF LAST UUO
CJRST4:	 JRST 4,.		;UUO NOT DEFINED
	JRST @UUODSP(A)		;GO TO IT


UUODSP:	CJRST4		;ZERO BITES
	.GET		;GIVE WORD FROM UFD CHAN BACK TO USER
	.SGEN		;STRING OUT TO BP7
	.SPRINT		;PRINT NUMBER IN RADIX RADIX TO BP7
	.FLOOK		;LOOKUP ON FILC, USE LUKDAT IF IT IS THERE, ADD IF NOT
	.REMOVE		;FLUSH CORE DATA ON THIS FILE
	.TYPE6		;SEND AC ASCII CHRS TO BP7 FROM E (IN SIXBIT)
	.TTY6		;SAME AS ABOVE, TO TTY
	.SGENA		;SGEN DAT SKIPS
LASUUO←←.-UUODSP-1

UUORET:	MOVSI 17,UUOACS		;BLT AC'S BACK AND RETURN
	BLT 17,17
	JRST @UUOH


COMMENT ⊗	GET uuo ⊗
.GET:	LDB A,[270400,,40]	;GET AC OF GET
	CAIN A,UFDC
	JRST .GET2
	CAIN A,MFDC
	JRST .GET3
	ERR 0,<Ill.  user uuo, GET to unimplemented chan.>
.GET3:	SOSLE MFDNUL+2
	JRST .GET4
	INPUT MFDC,
	STATO MFDC,20000
.GET4:	AOS UUOH
	ILDB A,MFDNUL+1
	HRRZ B,40
	CAIG B,17
	MOVEM A,UUOACS(B)
	MOVEM A,(B)
	JRST UUORET

.GET2:	SOSLE UFDNUL+2		;DECREMENT BYTE POINTER IN HEADER
	JRST .GET1		;ITS OK
	INPUT UFDC,		;DO AN INPUT
	STATO UFDC,20000	;DON'T SKIP RETURN IF YOU HAVE HIT THE END OF FILE
.GET1:	AOS UUOH		;TO CAUSE SKIP RETURN
	ILDB A,UFDNUL+1		;YUM
	HRRZ B,40		;WHERE DOES HE WANT ME TO PUT THIS?
	CAIG B,17		;SKIP IF GOING TO MEMORY RATHER THAN AN AC
	MOVEM A,UUOACS(B)	;STUFF IT IN AC
	MOVEM A,(B)		;OR STUFF IT IN MEM.
	JRST UUORET	;THAT IS IT

.TAKE:	0		;JSR'D TO BY OTHER UUOS
	AOS .TAKE	;ALWAYS SKIP RETURNS
	MOVEM A,.TAKAS	;SAVE A
	MOVE A,.TAKE	;NOW FIND OUT WHAT THE AC OF THE JSR IS
	LDB A,[270400,,-1(A)]
	CAIN A,A	;WAS THIS GUY USING THE AC WE CHOSE TO USE HERE?
	SKIPA A,.TAKAS	;YEP, GET OLD STUFF BACK FOR OUTPUTING
	MOVE A,(A)	;NO, SET UP A WITH CONT. OF AC HE GAVE US
	SOSLE DELBLK+2
	JRST .TAKE1
	OUTPUT FIL,	;IT HAPPENS
.TAKE1:	IDPB A,DELBLK+1	;YUMMY.  GOBBLE LUSERS DATA
	MOVE A,.TAKAS	;GIVE HIM HIS OLD A BACK
	JRST @.TAKE
.TAKAS:	-1		;HIDE A HERE WHILE DOIN THIS
COMMENT ⊗	SGEN uuo ⊗
.SGENA:	AOS UUOH		;SKIP
.SGEN:	SETZ B,
	MOVE A,40		;FOR THE ADDRESS OF INPUT TEXT
	HRLI A,440700		;MAKE A BYTE POINTER OUT OF IT
.SGEN0:	ILDB B,A		;GET A CHARACTER FROM STRING CALLING US
	JUMPE B,UUORET		;THAT'S IT FOR THIS STRING
	TRNE F,%DEVUO		;DIRECT IF WE SHOULD OUTPUT TO FIL CHANEL
	JSR B,.TAKE		; DO THAT AND SKIP OVER IDPB
	IDPB B,BP7		;DROP IT IN BP7
	JRST .SGEN0

COMMENT ⊗	SPRINT uuo ⊗
.SPRIN:	LDB C,[270400,,40]		;GET AC FIELD OF UUO
	HRRZ A,40			;GET E OF UUO
	CAIGE A,20			;SKIP IF E OF UUO IS MEMORY RATHER THAN AC
	SKIPA A,UUOACS(A)		;LOAD FROM BLTED AWAY AC'S
	MOVE A,(A)			;OF FROM MEMORY
	PUSH P,[UUORET]			;CRANK OUT DIGITS
.SPR1:	IDIV A,C		;C CONTAINS RADIX FROM AC FIELD OF UUO
	HRLM B,(P)
	SKIPE A
	PUSHJ P,.SPR1
	LDB B,[220600,,(P)]
	TRCE B,=48
	SETOM CCT
	TRNE F,%DEVUO		;DIRECT IF WE SHOULD DO IO TO A DEVICE
	JSR B,.TAKE		;DO THAT, AND SKIP OVER IDPB
	IDPB B,BP7
	AOS B,CCT
	POPJ P,
CCT:	-69
COMMENT ⊗ 	FLOOKUP uuo ⊗
.FLOOK:	MOVEI A,UFDIN	;ADDRESS OF THE BLOCK
	MOVE B,(A)	;GET THE FIRST FILE NAME HE WANTS
	HLLZ C,1(A)	;GET THE EXT
	MOVEI A,	;IDX INTO THE LUKDAT TAB
.FLL1:	SETO D,
	CAMN D,LUKDAT(A);IS THIS THE END OF TAB?
	JRST .FL3	;YES, WILL HAVE TO DO REAL LOOKUP
	CAME B,LUKDAT(A);DOES THE FIRST FILE NAME MATCH
	JRST .FL2	;NO, TRY NEXT
	HLLZ D,LUKDAT+1(A)	;GET THE EXT FROM LUKDAT
	CAME C,D	;DOES THE EXT MATCH?
	JRST .FL2	;NO
	MOVE D,UFDIN+3
	CAMN D,LUKDAT+6(A)	;PPN MATCH?
	JRST .FL4	;YES, BLT HIM THE DATA
.FL2:	ADDI A,7	;NO, TRY NEXT ENTRY IN LUKDAT
	JRST .FLL1
.FL4:	HRLZ A,A	;BLT DATA IN LUKDAT(A) TO UFDIN
	ADD A,[LUKDAT,,UFDIN]
	BLT A,UFDIN+5	;GIVE HIM THE BITS
	AOS UUOH	;SKIP RETURN, HE WINS
	JRST UUORET
.FL3:	MOVE D,UFDIN+3	;HOLD ONTO THE PPN, WE WILL NEED IT FOR PUTTING THIS LOOKUP IN LUKDAT
	LOOKUP FILC,UFDIN
	 JRST .FLERR	;CAN'T LOOK IT UP, DO THE RIGHT THING IF IT WAS A PROTECT FAIL
	AOS UUOH	;SKIP RETURN HE WINS
.FLL2B:	MOVEI A,		;FIND THE FIRST FREE BLOCK IN LUKDAT
.FLL2:	MOVE C,LUKDAT(A);GET THE FIRST WORD IN BLOCK IN LUKDAT
	CAME C,[-1]	;IF IT IS -1 OR 0 IT IS EITHER THE END OF THE TABLE 
	CAIN C,		; (FREE CELL AT END) OR HOLE IN THE MIDDLE (REMOVED BEFORE)
	JRST .FL5	;FOUND A FREE CELL
	ADDI A,7	;ENTRIES IN LUKDAT ARE 7 LONG
	JRST .FLL2	;LOOP
.FL5:	MOVE B,A	;FOR BLT
	ADD B,[UFDIN,,LUKDAT]
	BLT B,LUKDAT+5(A)	;PUT INFO IN LUKDAT FOR FUTURE REF.
	MOVEM D,LUKDAT+6(A)	;PUT THIS PPN AWAY WITH THIS TOO
	JRST UUORET
.FLERR:	HRRZ A,UFDIN+1	;SEE IF LOOKUP FAILED FOR PROTECTION REASONS
	CAIE A,2	;2 IS PROTECT
	CAIN A,		;0 IS FILE NOT FOUND, IE IS BEING WRITTEN
	JRST .FLER1
	CAIE A,3	;3 IS FILE IN USE,  ALL OF THESE ARE 'OK ERRORS'
	 JRST FATL09
.FLER1:	SETZM UFDIN+3	;GUY MAY LOOK AT THIS WORD COUNT
	JRST UUORET
COMMENT ⊗ 	REMOVE uuo ⊗

.REMOV:	HRRZ A,40	;GET E OF UUO
	CAIL A,20	;SKIP IF IT IS AN AC
	SKIPA A,(A)	;GET FROM MEMORY
	MOVE A,UUOACS(A);GET FROM SAVED USER ACS
	MOVE B,FILES(A)	;GET IDX INTO UFD
	MOVE C,UFD(B)	;GET FIRST FILE NAME WE ARE TO REMOVE
	MOVE D,UFD2(B)	;GET EXT, NOW LOOK FOR IT IN LUKDAT TABLE
	MOVE I,LLUSER(B)
	LDB E,[270400,,40]	;GET AC F. OF UUO
	CAIN E,1		;AC OF ONE MEANS DONT ACTUALLY MUNCH LUKDAT
	JRST .REMO3
	MOVEI E,NFILES
	MOVEI B,	;WE USE B FOR IDX INTO LUKDAT
.REMO1:	SOJL E,.REMOE	;NEVER GET THERE, MEANS WE COULD NOT FIND THIS FILE IN LUKDAT
	CAMN C,LUKDAT(B); DIRECT IF FIRST FILE NAME MATCHES FOR THIS ENTRY
	CAME D,LUKDAT+1(B) ; SKIP IF EXT MATCHES 
	JRST .REMO4
	CAMN I,LUKDAT+6(B)	;DIRECT IF WE HAVE A WINNER, EVERYTHING MATCHES
	JRST .REMO2	;GOT IT IN E
.REMO4:	ADDI B,7	;TRY NEXT LUKDAT ENTRY
	JRST .REMO1
.REMO2:	SETZM LUKDAT(B)	;ZERO IN 1ST WD OF BLOK IN LUKDAT MARKS FREE BLOK
	MOVS B,LUKDAT+3(B)	;4TH WORD OF LUKUP BLOK HAS -SWPD WORD COUNT
	ADDM B,WORDS		;SO MAKE IT LOOK LIKE WE HAVE REALLY DELETED THIS
				; FILE TO HIS WORD COUNT.
.REMO3:	ADDI A,FILES
	HRLI A,1(A)	;A HAS 'FILES' IDX, MAKE BLT AC OUT OF IT TO REMOVE
	BLT A,FILES+NFILES-1	; THIS FILE FROM DISPLAY LIST
	JRST UUORET
.REMOE:	ERR 0,<Fatal Error in REMOVE uuo.  Files specifed is not in LUKDAT table.>
COMMENT ⊗ 	TYPE6 uuo ⊗
.TYPE6:	LDB A,[270400,,40]	;GET AC OF UUO (RPT COUNT ON OUTPUTING CHRS)
	HRRZ B,40		;USE E OF UUO FOR GETTING CHRS
	CAIGE B,20		;DIRECT IFF CHRS ARE COMMING FROM USER ACS
	ADDI B,UUOACS		; CAUSE IT TO POINT AT SAVED USER ACS
	HRLI B,440600		;MAKE A SIXBIT BYTE POINTER OUT OF E OF UO
TYPE61:	SOJL A,UUORET		;OUTPUT AC CHRS BY... 
	ILDB C,B		;GET A SIXBIT CHR 
	ADDI C,40		;MAKE ASCII OUT OF IT
	TRNE F,%DEVUO		; 1==> OUTPUT TO A DEVICE ON FIL CHAN.
	JSR C,.TAKE		;WILL SKIP RETURN
	IDPB C,BP7		;STUFF IT AWAY IN BP7
	JRST TYPE61
COMMENT ⊗ 	TTY6 uuo ⊗
.TTY6:	LDB A,[270400,,40]	;GET AC OF UUO (RPT COUNT ON OUTPUTING CHRS)
	HRRZ B,40		;USE E OF UUO FOR GETTING CHRS
	CAIGE B,20		;DIRECT IFF CHRS ARE COMMING FROM USER ACS
	ADDI B,UUOACS		; CAUSE IT TO POINT AT SAVED USER ACS
	HRLI B,440600		;MAKE A SIXBIT BYTE POINTER OUT OF E OF UO
.TTY61:	SOJL A,UUORET		;OUTPUT AC CHRS BY... 
	ILDB C,B		;GET A SIXBIT CHR 
	ADDI C,40		;MAKE ASCII OUT OF IT
	OUTCHR C		;STUFF IT AWAY IN BP7
	JRST .TTY61
COMMENT ⊗ Usage lossage ⊗
USTATS:	GETPPN A,	;DON'T BOTHER WITH THIS STUFF FR ME, I KNOW ABOUT IT
	CAMN A,['105SGK']
	POPJ P,
	INIT UFDC,	;USE UFD CHAN FOR INPUT
	SIXBIT /DSK/
	UFDNUL
	 JRST USTATE	;GIVE UP IF WE CAN'T INIT
	INIT FIL,
	SIXBIT /DSK/
	DELBLK,,
	 JRST USTATE
	MOVE A,[['DIRED '↔'USE   '↔0↔'105SGK'],,USTFOO]
	BLT A,USTFOO+3
	LOOKUP UFDC,USTFOO
	 JRST USTATE
	MOVE A,[['DIRED '↔'USE   '↔0↔'105SGK'],,USTFOO]
	BLT A,USTFOO+3
	ENTER FIL,USTFOO
	 JRST USTATE
	TRO F,%DEVUO
USTA1:	PUSHJ P,.USI
	CAIN A,"β"
	JRST USTA2
	PUSHJ P,.USO
	JRST USTA1
USTA2:	TRNN F,%START	;DIRECT RETURN IF THIS IS THE FIRST TIME HERE
	SGENA [ASCIZ /*/];INDICATE HERE IS WHERE THE GUY STARTED DIRED
	SGEN [ASCIZ / /] ;INDICATE WE GOT HERE BECAUSE OF A αβM OR [ TO DIRED
	GETPPN A,
	TYPE6 6,A
	SGEN [ASCIZ /  /]
	SGEN [ASCIZ *[*]
	TYPE6 6,LUSER
	SGEN [ASCIZ /] /]
	TRNE F,%TTY		;ON A PRINTING TTY?	;PRINT <TTY TYPE><LINE NUMBER>
	JRST	[SGEN [ASCIZ /TTY/]	;DEVICE NAME
		JRST USTTYT]		;IGNORE %GETTY BIT
	TRNE F,%GETTY		;DIRECT ON III	
	SGENA [ASCIZ /III/]
	SGEN [ASCIZ / DD/]
USTTYT:	GETLN A,	;THIS GIVES THE SIXBIT OF THE TTY WE ARE ON
	MOVS A,A	;GET THE 3 CHRS ON LINE NUMBER IN LEFT HALS
	TYPE6 3,A	;CRANK THEM OUT
	SGEN [ASCIZ /  /]
	DATE A,
	IDIVI A,=31
	ADDI B,1	;REMAINDER IS DAY-1
	CAIGE B,=10	;IF LESS THAN 10 TYPE A SPACE TO FORCE IT TO TAKE 2 POS.
	SGEN [ASCIZ / /];LIKE I SAID, NUMBER ONE DIGIT, TAKE 2 POSITIONS
	SPRINT =10,B	;CRANK DAY OUT
	IDIVI A,=12
	XCT MONTHS(B)	;UUO WILL PRINT NAME OF MONTH
	ADDI A,=64	;OR 1964 FOR FULL YEAR NUMBER,,,,
	SPRINT =10,A	;GUESS
	SGEN [ASCIZ/  /];BLOOD IS THICKER THAN PRUNE JUICE
	TIMER A,
	IDIVI A,=3600
	IDIVI A,=60
	MOVEM B,.USTT#
	IDIVI A,=10
	SPRINT 12,A
	SPRINT 12,B
	MOVE A,.USTT
	IDIVI A,=10
	SPRINT 12,A
	SPRINT 12,B
	SGEN [ASCIZ /  /]	;TAB FOR TYPE OF DEVICE
USTT1:	SGEN [ASCIZ /   /]	;TAB FOR BEGINING OF SWITCHES
	TRNE F,%ORDER		;DIRECT FOR REVERSE SORT
	SGEN [ASCIZ */REV*]
	
	TRNE F,%SZSRTS		;SKIP IF SIZE SORT OUT OF RUNNING, LOOK AT %SORT & %XTSRT
	JRST [	SGEN [ASCIZ */SIZE*]
		JRST USTTSR]	;DONT CONSIDER ANY OTHER SORT SWITCHES

	TRNN F,%SORT		;SKIP IF SORT BY DATE
	JRST [	TRNE F,%XTSRT	;MAY BE ALPHA SORT OR EXT SORT
		SGENA [ASCIZ */EXT*]
		SGEN [ASCIZ */ALPHA*]
		JRST USTTSR]	;SKIP OVER SGEN FOR DATE SWITCH
	SGEN [ASCIZ */DATE*]	;HE IS DATE SORTING

USTTSR:	TRNE F,%FAST		;DIRECT IF IN FAST MODE
	SGENA [ASCIZ */FAST*]
	SGEN [ASCIZ */FULL*]
	SPRINT 8,[-36]
	TRZ F,%DEVUO
USTATE:	CLOSE UFDC,
	CLOSE FIL,
	POPJ P,

.USI:	SOSLE UFDNUL+2
	JRST .USI1
	INPUT UFDC,
	STATZ UFDC,20000
	SKIPA A,["β"]
.USI1:	ILDB A,UFDNUL+1
	CAIN A,		;DONT GIVE THE USER 0
	JRST .USI
	POPJ P,

.USO:	SOSLE DELBLK+2
	JRST .USO1
	OUTPUT FIL,
.USO1:	IDPB A,DELBLK+1
	POPJ P,
USTFOO:	BLOCK 4
END GO